parent
b10c8a6fc3
commit
9016794111
|
|
@ -40,6 +40,6 @@ else
|
|||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("api/SampleData/WeatherForecasts");
|
||||
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("weatherforecast");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,16 +7,24 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace BlazorHosted_CSharp.Server.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
public class SampleDataController : Controller
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static string[] Summaries = new[]
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
[HttpGet("[action]")]
|
||||
public IEnumerable<WeatherForecast> WeatherForecasts()
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
var rng = new Random();
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
|
|
@ -24,7 +32,8 @@ namespace BlazorHosted_CSharp.Server.Controllers
|
|||
Date = DateTime.Now.AddDays(index),
|
||||
TemperatureC = rng.Next(-20, 55),
|
||||
Summary = Summaries[rng.Next(Summaries.Length)]
|
||||
});
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Controllers/WeatherController.fs" />
|
||||
<Compile Include="WeatherForecast.fs" />
|
||||
<Compile Include="Controllers/WeatherForecastController.fs" />
|
||||
<Compile Include="Startup.fs" />
|
||||
<Compile Include="Program.fs" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -9,11 +9,12 @@ namespace GrpcService_CSharp
|
|||
{
|
||||
public class GreeterService : Greeter.GreeterBase
|
||||
{
|
||||
private readonly ILogger<GreeterService> logger;
|
||||
public GreeterService(ILogger<GreeterService> _logger)
|
||||
private readonly ILogger<GreeterService> _logger;
|
||||
public GreeterService(ILogger<GreeterService> logger)
|
||||
{
|
||||
logger = _logger;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public override Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context)
|
||||
{
|
||||
return Task.FromResult(new HelloReply
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace RazorComponentsWeb_CSharp.Data
|
|||
{
|
||||
public class WeatherForecastService
|
||||
{
|
||||
private static string[] Summaries = new[]
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,12 +16,13 @@ namespace Company.WebApplication1.Pages
|
|||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
|
||||
private readonly ILogger<ErrorModel> logger;
|
||||
private readonly ILogger<ErrorModel> _logger;
|
||||
|
||||
public ErrorModel(ILogger<ErrorModel> _logger)
|
||||
public ErrorModel(ILogger<ErrorModel> logger)
|
||||
{
|
||||
logger = _logger;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
|
||||
|
|
|
|||
|
|
@ -10,12 +10,13 @@ namespace Company.WebApplication1.Pages
|
|||
{
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly ILogger<IndexModel> logger;
|
||||
private readonly ILogger<IndexModel> _logger;
|
||||
|
||||
public IndexModel(ILogger<IndexModel> _logger)
|
||||
public IndexModel(ILogger<IndexModel> logger)
|
||||
{
|
||||
logger = _logger;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -10,12 +10,13 @@ namespace Company.WebApplication1.Pages
|
|||
{
|
||||
public class PrivacyModel : PageModel
|
||||
{
|
||||
private readonly ILogger<PrivacyModel> logger;
|
||||
private readonly ILogger<PrivacyModel> _logger;
|
||||
|
||||
public PrivacyModel(ILogger<PrivacyModel> _logger)
|
||||
public PrivacyModel(ILogger<PrivacyModel> logger)
|
||||
{
|
||||
logger = _logger;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
#endif
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Company.WebApplication1.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Company.WebApplication1.Models;
|
||||
|
||||
namespace Company.WebApplication1.Controllers
|
||||
{
|
||||
|
|
@ -17,12 +17,13 @@ namespace Company.WebApplication1.Controllers
|
|||
#endif
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> logger;
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
|
||||
public HomeController(ILogger<HomeController> _logger)
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
{
|
||||
logger = _logger;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
|
|
|
|||
|
|
@ -7,9 +7,8 @@ open System.Threading.Tasks
|
|||
open Microsoft.AspNetCore.Mvc
|
||||
open Microsoft.Extensions.Logging
|
||||
|
||||
type HomeController (_logger : ILogger<HomeController>) =
|
||||
type HomeController (logger : ILogger<HomeController>) =
|
||||
inherit Controller()
|
||||
let mutable logger = _logger
|
||||
|
||||
member this.Index () =
|
||||
this.View()
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
#if (!NoAuth)
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
#endif
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Company.WebApplication1.Controllers
|
||||
{
|
||||
#if (!NoAuth)
|
||||
[Authorize]
|
||||
#endif
|
||||
|
||||
[Route("api/SampleData/[controller]")]
|
||||
[ApiController]
|
||||
public class WeatherController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<WeatherController> logger;
|
||||
|
||||
public WeatherController(ILogger<WeatherController> _logger)
|
||||
{
|
||||
logger = _logger;
|
||||
}
|
||||
[HttpGet]
|
||||
public ActionResult<WeatherResult> GetWeatherForecasts(string location, TemperatureUnit unit)
|
||||
{
|
||||
var rng = new Random();
|
||||
return new WeatherResult
|
||||
{
|
||||
Location = location,
|
||||
Temperature = rng.Next(-20, 55),
|
||||
TemperatureUnit = unit
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public enum TemperatureUnit
|
||||
{
|
||||
Celsius,
|
||||
Fahrenheit
|
||||
}
|
||||
public class WeatherResult
|
||||
{
|
||||
public int Temperature { get; set; }
|
||||
public TemperatureUnit TemperatureUnit { get; set; }
|
||||
public string Location { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
#if (!NoAuth)
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
#endif
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Company.WebApplication1.Controllers
|
||||
{
|
||||
#if (!NoAuth)
|
||||
[Authorize]
|
||||
#endif
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
var rng = new Random();
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateTime.Now.AddDays(index),
|
||||
TemperatureC = rng.Next(-20, 55),
|
||||
Summary = Summaries[rng.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
|
||||
namespace Company.WebApplication1
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string Summary { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
namespace WebApplication1.Controllers
|
||||
|
||||
open System
|
||||
open System.Collections.Generic
|
||||
open System.Linq
|
||||
open System.Threading.Tasks
|
||||
open Microsoft.AspNetCore.Mvc
|
||||
open Microsoft.Extensions.Logging
|
||||
|
||||
type public TemperatureUnit =
|
||||
| Celsius=0
|
||||
| Fahrenheit=1
|
||||
|
||||
type WeatherResult = {
|
||||
Location: string
|
||||
TemperatureUnit: TemperatureUnit
|
||||
Temperature: int
|
||||
}
|
||||
|
||||
[<Route("api/SampleData/[controller]")>]
|
||||
[<ApiController>]
|
||||
type WeatherController (_logger : ILogger<WeatherController>) =
|
||||
inherit ControllerBase()
|
||||
let mutable logger = _logger
|
||||
|
||||
[<HttpGet>]
|
||||
member this.Get(location:string, unit: TemperatureUnit) =
|
||||
let rnd = System.Random()
|
||||
let result:WeatherResult = {
|
||||
Location = location;
|
||||
Temperature = rnd.Next(-20,55);
|
||||
TemperatureUnit = unit
|
||||
}
|
||||
ActionResult<WeatherResult>(result)
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
namespace Company.WebApplication1.Controllers
|
||||
|
||||
open System
|
||||
open System.Collections.Generic
|
||||
open System.Linq
|
||||
open System.Threading.Tasks
|
||||
open Microsoft.AspNetCore.Mvc
|
||||
open Microsoft.Extensions.Logging
|
||||
open Company.WebApplication1
|
||||
|
||||
[<ApiController>]
|
||||
[<Route("[controller]")>]
|
||||
type WeatherForecastController (logger : ILogger<WeatherForecastController>) =
|
||||
inherit ControllerBase()
|
||||
|
||||
let summaries = [| "Freezing"; "Bracing"; "Chilly"; "Cool"; "Mild"; "Warm"; "Balmy"; "Hot"; "Sweltering"; "Scorching" |]
|
||||
|
||||
[<HttpGet>]
|
||||
member __.Get() : WeatherForecast[] =
|
||||
let rng = System.Random()
|
||||
[|
|
||||
for index in 0..4 ->
|
||||
{ Date = DateTime.Now.AddDays(float index)
|
||||
TemperatureC = rng.Next(-20,55)
|
||||
Summary = summaries.[rng.Next(summaries.Length)] }
|
||||
|]
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
namespace Company.WebApplication1
|
||||
|
||||
open System
|
||||
|
||||
type WeatherForecast =
|
||||
{ Date: DateTime
|
||||
TemperatureC: int
|
||||
Summary: string }
|
||||
|
||||
member this.TemperatureF =
|
||||
32 + (int (float this.TemperatureC / 0.5556))
|
||||
|
|
@ -9,7 +9,7 @@ export class FetchDataComponent {
|
|||
public forecasts: WeatherForecast[];
|
||||
|
||||
constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string) {
|
||||
http.get<WeatherForecast[]>(baseUrl + 'api/SampleData/WeatherForecasts').subscribe(result => {
|
||||
http.get<WeatherForecast[]>(baseUrl + 'weatherforecast').subscribe(result => {
|
||||
this.forecasts = result;
|
||||
}, error => console.error(error));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
#if (IndividualLocalAuth)
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
#endif
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Company.WebApplication1.Controllers
|
||||
{
|
||||
#if (IndividualLocalAuth)
|
||||
[Authorize]
|
||||
#endif
|
||||
[Route("api/[controller]")]
|
||||
public class SampleDataController : Controller
|
||||
{
|
||||
private readonly ILogger<SampleDataController> logger;
|
||||
|
||||
public SampleDataController(ILogger<SampleDataController> _logger)
|
||||
{
|
||||
logger = _logger;
|
||||
}
|
||||
private static string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
[HttpGet("[action]")]
|
||||
public IEnumerable<WeatherForecast> WeatherForecasts()
|
||||
{
|
||||
var rng = new Random();
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
DateFormatted = DateTime.Now.AddDays(index).ToString("d"),
|
||||
TemperatureC = rng.Next(-20, 55),
|
||||
Summary = Summaries[rng.Next(Summaries.Length)]
|
||||
});
|
||||
}
|
||||
|
||||
public class WeatherForecast
|
||||
{
|
||||
public string DateFormatted { get; set; }
|
||||
public int TemperatureC { get; set; }
|
||||
public string Summary { get; set; }
|
||||
|
||||
public int TemperatureF
|
||||
{
|
||||
get
|
||||
{
|
||||
return 32 + (int)(TemperatureC / 0.5556);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
#if (!NoAuth)
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
#endif
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Company.WebApplication1.Controllers
|
||||
{
|
||||
#if (!NoAuth)
|
||||
[Authorize]
|
||||
#endif
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
var rng = new Random();
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateTime.Now.AddDays(index),
|
||||
TemperatureC = rng.Next(-20, 55),
|
||||
Summary = Summaries[rng.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,12 +12,13 @@ namespace Company.WebApplication1.Pages
|
|||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public class ErrorModel : PageModel
|
||||
{
|
||||
private readonly ILogger<ErrorModel> logger;
|
||||
private readonly ILogger<ErrorModel> _logger;
|
||||
|
||||
public ErrorModel(ILogger<ErrorModel> _logger)
|
||||
public ErrorModel(ILogger<ErrorModel> logger)
|
||||
{
|
||||
logger = _logger;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public string RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
|
||||
namespace Company.WebApplication1
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string Summary { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -57,13 +57,13 @@ export class FetchData extends Component {
|
|||
async populateWeatherData() {
|
||||
////#if (IndividualLocalAuth)
|
||||
const token = await authService.getAccessToken();
|
||||
const response = await fetch('api/SampleData/WeatherForecasts', {
|
||||
const response = await fetch('weatherforecast', {
|
||||
headers: !token ? {} : { 'Authorization': `Bearer ${token}` }
|
||||
});
|
||||
const data = await response.json();
|
||||
this.setState({ forecasts: data, loading: false });
|
||||
////#else
|
||||
const response = await fetch('api/SampleData/WeatherForecasts');
|
||||
const response = await fetch('weatherforecast');
|
||||
const data = await response.json();
|
||||
this.setState({ forecasts: data, loading: false });
|
||||
////#endif
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ namespace Company.WebApplication1.Controllers
|
|||
{
|
||||
public class OidcConfigurationController : Controller
|
||||
{
|
||||
private readonly ILogger<OidcConfigurationController> logger;
|
||||
private readonly ILogger<OidcConfigurationController> _logger;
|
||||
|
||||
public OidcConfigurationController(IClientRequestParametersProvider clientRequestParametersProvider, ILogger<OidcConfigurationController> _logger)
|
||||
public OidcConfigurationController(IClientRequestParametersProvider clientRequestParametersProvider, ILogger<OidcConfigurationController> logger)
|
||||
{
|
||||
ClientRequestParametersProvider = clientRequestParametersProvider;
|
||||
logger = _logger;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public IClientRequestParametersProvider ClientRequestParametersProvider { get; }
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
#if (IndividualLocalAuth)
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
#endif
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Company.WebApplication1.Controllers
|
||||
{
|
||||
#if (IndividualLocalAuth)
|
||||
[Authorize]
|
||||
#endif
|
||||
[Route("api/[controller]")]
|
||||
public class SampleDataController : Controller
|
||||
{
|
||||
private readonly ILogger<SampleDataController> logger;
|
||||
|
||||
public SampleDataController(ILogger<SampleDataController> _logger)
|
||||
{
|
||||
logger = _logger;
|
||||
}
|
||||
private static string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
[HttpGet("[action]")]
|
||||
public IEnumerable<WeatherForecast> WeatherForecasts()
|
||||
{
|
||||
var rng = new Random();
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
DateFormatted = DateTime.Now.AddDays(index).ToString("d"),
|
||||
TemperatureC = rng.Next(-20, 55),
|
||||
Summary = Summaries[rng.Next(Summaries.Length)]
|
||||
});
|
||||
}
|
||||
|
||||
public class WeatherForecast
|
||||
{
|
||||
public string DateFormatted { get; set; }
|
||||
public int TemperatureC { get; set; }
|
||||
public string Summary { get; set; }
|
||||
|
||||
public int TemperatureF
|
||||
{
|
||||
get
|
||||
{
|
||||
return 32 + (int)(TemperatureC / 0.5556);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
#if (!NoAuth)
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
#endif
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Company.WebApplication1.Controllers
|
||||
{
|
||||
#if (!NoAuth)
|
||||
[Authorize]
|
||||
#endif
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
var rng = new Random();
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateTime.Now.AddDays(index),
|
||||
TemperatureC = rng.Next(-20, 55),
|
||||
Summary = Summaries[rng.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -12,12 +12,13 @@ namespace Company.WebApplication1.Pages
|
|||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public class ErrorModel : PageModel
|
||||
{
|
||||
private readonly ILogger<ErrorModel> logger;
|
||||
private readonly ILogger<ErrorModel> _logger;
|
||||
|
||||
public ErrorModel(ILogger<ErrorModel> _logger)
|
||||
public ErrorModel(ILogger<ErrorModel> logger)
|
||||
{
|
||||
logger = _logger;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public string RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
|
||||
namespace Company.WebApplication1
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string Summary { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ export const actionCreators = {
|
|||
// Only load data if it's something we don't already have (and are not already loading)
|
||||
const appState = getState();
|
||||
if (appState && appState.weatherForecasts && startDateIndex !== appState.weatherForecasts.startDateIndex) {
|
||||
fetch(`api/SampleData/WeatherForecasts?startDateIndex=${startDateIndex}`)
|
||||
fetch(`weatherforecast`)
|
||||
.then(response => response.json() as Promise<WeatherForecast[]>)
|
||||
.then(data => {
|
||||
dispatch({ type: 'RECEIVE_WEATHER_FORECASTS', startDateIndex: startDateIndex, forecasts: data });
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Company.WebApplication1.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
public class SampleDataController : Controller
|
||||
{
|
||||
private readonly ILogger<SampleDataController> logger;
|
||||
|
||||
public SampleDataController(ILogger<SampleDataController> _logger)
|
||||
{
|
||||
logger = _logger;
|
||||
}
|
||||
private static string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
[HttpGet("[action]")]
|
||||
public IEnumerable<WeatherForecast> WeatherForecasts(int startDateIndex)
|
||||
{
|
||||
var rng = new Random();
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
DateFormatted = DateTime.Now.AddDays(index + startDateIndex).ToString("d"),
|
||||
TemperatureC = rng.Next(-20, 55),
|
||||
Summary = Summaries[rng.Next(Summaries.Length)]
|
||||
});
|
||||
}
|
||||
|
||||
public class WeatherForecast
|
||||
{
|
||||
public string DateFormatted { get; set; }
|
||||
public int TemperatureC { get; set; }
|
||||
public string Summary { get; set; }
|
||||
|
||||
public int TemperatureF
|
||||
{
|
||||
get
|
||||
{
|
||||
return 32 + (int)(TemperatureC / 0.5556);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
#if (!NoAuth)
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
#endif
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Company.WebApplication1.Controllers
|
||||
{
|
||||
#if (!NoAuth)
|
||||
[Authorize]
|
||||
#endif
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
var rng = new Random();
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateTime.Now.AddDays(index),
|
||||
TemperatureC = rng.Next(-20, 55),
|
||||
Summary = Summaries[rng.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
|
||||
namespace Company.WebApplication1
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string Summary { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ namespace Templates.Test
|
|||
aspNetProcess.Process.HasExited,
|
||||
ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", Project, aspNetProcess.Process));
|
||||
|
||||
await aspNetProcess.AssertOk("/api/SampleData/Weather");
|
||||
await aspNetProcess.AssertOk("weatherforecast");
|
||||
await aspNetProcess.AssertNotFound("/");
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ namespace Templates.Test
|
|||
ErrorMessages.GetFailedProcessMessageOrEmpty("Run published project", Project, aspNetProcess.Process));
|
||||
|
||||
|
||||
await aspNetProcess.AssertOk("/api/SampleData/Weather");
|
||||
await aspNetProcess.AssertOk("weatherforecast");
|
||||
await aspNetProcess.AssertNotFound("/");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -398,7 +398,8 @@
|
|||
"appsettings.json",
|
||||
"Program.cs",
|
||||
"Startup.cs",
|
||||
"Controllers/WeatherController.cs",
|
||||
"WeatherForecast.cs",
|
||||
"Controllers/WeatherForecastController.cs",
|
||||
"Properties/launchSettings.json"
|
||||
],
|
||||
"AuthOption": "IndividualB2C"
|
||||
|
|
@ -411,7 +412,8 @@
|
|||
"appsettings.json",
|
||||
"Program.cs",
|
||||
"Startup.cs",
|
||||
"Controllers/WeatherController.cs",
|
||||
"WeatherForecast.cs",
|
||||
"Controllers/WeatherForecastController.cs",
|
||||
"Properties/launchSettings.json"
|
||||
],
|
||||
"AuthOption": "SingleOrg"
|
||||
|
|
@ -424,7 +426,8 @@
|
|||
"appsettings.json",
|
||||
"Program.cs",
|
||||
"Startup.cs",
|
||||
"Controllers/WeatherController.cs",
|
||||
"WeatherForecast.cs",
|
||||
"Controllers/WeatherForecastController.cs",
|
||||
"Properties/launchSettings.json"
|
||||
],
|
||||
"AuthOption": "None"
|
||||
|
|
@ -437,7 +440,8 @@
|
|||
"appsettings.json",
|
||||
"Program.cs",
|
||||
"Startup.cs",
|
||||
"Controllers/WeatherController.cs",
|
||||
"WeatherForecast.cs",
|
||||
"Controllers/WeatherForecastController.cs",
|
||||
"Properties/launchSettings.json"
|
||||
],
|
||||
"AuthOption": "Windows"
|
||||
|
|
@ -450,7 +454,8 @@
|
|||
"appsettings.json",
|
||||
"Program.fs",
|
||||
"Startup.fs",
|
||||
"Controllers/WeatherController.fs",
|
||||
"WeatherForecast.fs",
|
||||
"Controllers/WeatherForecastController.fs",
|
||||
"Properties/launchSettings.json"
|
||||
]
|
||||
}
|
||||
|
|
@ -1157,7 +1162,8 @@
|
|||
"ClientApp/README.md",
|
||||
"ClientApp/tsconfig.json",
|
||||
"ClientApp/tslint.json",
|
||||
"Controllers/SampleDataController.cs",
|
||||
"WeatherForecast.cs",
|
||||
"Controllers/WeatherForecastController.cs",
|
||||
"Pages/_ViewImports.cshtml",
|
||||
"Pages/Error.cshtml",
|
||||
"Pages/Error.cshtml.cs",
|
||||
|
|
@ -1194,7 +1200,8 @@
|
|||
"ClientApp/package-lock.json",
|
||||
"ClientApp/package.json",
|
||||
"ClientApp/README.md",
|
||||
"Controllers/SampleDataController.cs",
|
||||
"WeatherForecast.cs",
|
||||
"Controllers/WeatherForecastController.cs",
|
||||
"Pages/_ViewImports.cshtml",
|
||||
"Pages/Error.cshtml",
|
||||
"Pages/Error.cshtml.cs",
|
||||
|
|
@ -1236,7 +1243,8 @@
|
|||
"ClientApp/package.json",
|
||||
"ClientApp/README.md",
|
||||
"ClientApp/tsconfig.json",
|
||||
"Controllers/SampleDataController.cs",
|
||||
"WeatherForecast.cs",
|
||||
"Controllers/WeatherForecastController.cs",
|
||||
"Pages/_ViewImports.cshtml",
|
||||
"Pages/Error.cshtml",
|
||||
"Pages/Error.cshtml.cs",
|
||||
|
|
|
|||
Loading…
Reference in New Issue