Initial commit
This commit is contained in:
42
Oqtane.Client/Modules/Weather/Index.razor
Normal file
42
Oqtane.Client/Modules/Weather/Index.razor
Normal file
@ -0,0 +1,42 @@
|
||||
@using Oqtane.Modules
|
||||
@using Oqtane.Client.Modules.Weather.Services
|
||||
@inherits ModuleBase
|
||||
|
||||
@if (forecasts == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Temp. (C)</th>
|
||||
<th>Temp. (F)</th>
|
||||
<th>Summary</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var forecast in forecasts)
|
||||
{
|
||||
<tr>
|
||||
<td>@forecast.Date.ToShortDateString()</td>
|
||||
<td>@forecast.TemperatureC</td>
|
||||
<td>@forecast.TemperatureF</td>
|
||||
<td>@forecast.Summary</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
@functions {
|
||||
WeatherForecast[] forecasts;
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
WeatherForecastService forecastservice = new WeatherForecastService();
|
||||
forecasts = await forecastservice.GetForecastAsync(DateTime.Now);
|
||||
}
|
||||
}
|
12
Oqtane.Client/Modules/Weather/Models/WeatherForecast.cs
Normal file
12
Oqtane.Client/Modules/Weather/Models/WeatherForecast.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace Oqtane.Client.Modules.Weather
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public int TemperatureC { get; set; }
|
||||
public int TemperatureF { get; set; }
|
||||
public string Summary { get; set; }
|
||||
}
|
||||
}
|
16
Oqtane.Client/Modules/Weather/Module.cs
Normal file
16
Oqtane.Client/Modules/Weather/Module.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Oqtane.Modules;
|
||||
|
||||
namespace Oqtane.Client.Modules.Weather
|
||||
{
|
||||
public class Module : IModule
|
||||
{
|
||||
public string Name { get { return "Weather"; } }
|
||||
public string Description { get { return "Displays random weather using a service"; } }
|
||||
public string Version { get { return "1.0.0"; } }
|
||||
public string Owner { get { return ""; } }
|
||||
public string Url { get { return ""; } }
|
||||
public string Contact { get { return ""; } }
|
||||
public string License { get { return ""; } }
|
||||
public string Dependencies { get { return ""; } }
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Client.Modules.Weather.Services
|
||||
{
|
||||
public interface IWeatherForecastService
|
||||
{
|
||||
Task<WeatherForecast[]> GetForecastAsync(DateTime startDate);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using Oqtane.Modules;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Oqtane.Client.Modules.Weather.Services
|
||||
{
|
||||
public class WeatherForecastService : IWeatherForecastService
|
||||
{
|
||||
private static string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
|
||||
{
|
||||
var rng = new Random();
|
||||
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = startDate.AddDays(index),
|
||||
TemperatureC = rng.Next(-20, 55),
|
||||
Summary = Summaries[rng.Next(Summaries.Length)]
|
||||
}).ToArray());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user