Initial commit

This commit is contained in:
oqtane
2019-05-04 20:32:08 -04:00
committed by Shaun Walker
parent 2f232eea7e
commit d71de1c21f
177 changed files with 8536 additions and 0 deletions

View 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);
}
}

View 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; }
}
}

View 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 ""; } }
}
}

View File

@ -0,0 +1,10 @@
using System;
using System.Threading.Tasks;
namespace Oqtane.Client.Modules.Weather.Services
{
public interface IWeatherForecastService
{
Task<WeatherForecast[]> GetForecastAsync(DateTime startDate);
}
}

View File

@ -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());
}
}
}