CORS, Theme, Better flow and dotnet tools
This commit is contained in:
@ -1,30 +1,22 @@
|
||||
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
||||
using Expose.MyIT.Shared.Models.Stateless;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Expose.MyIT.Server.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class AppSettingsController : ControllerBase, IAppSettingsController
|
||||
[Route("api/[controller]")]
|
||||
public class AppSettingsController : ControllerBase, IAppSettingsController<ActionResult>
|
||||
{
|
||||
|
||||
private readonly Models.AppSettings _AppSettings;
|
||||
private readonly IAppSettingsRepository _AppSettingsRepository;
|
||||
|
||||
public AppSettingsController(Models.AppSettings appSettings) => _AppSettings = appSettings;
|
||||
public AppSettingsController(IAppSettingsRepository AppSettingsRepository) => _AppSettingsRepository = AppSettingsRepository;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[HttpGet]
|
||||
public string[] GetAppSettings()
|
||||
[HttpGet(nameof(IAppSettingsController<ActionResult>.Action.App))]
|
||||
public ActionResult GetAppSettings()
|
||||
{
|
||||
List<string> results = new();
|
||||
string json = JsonSerializer.Serialize(_AppSettings);
|
||||
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
|
||||
JsonProperty[] jsonProperties = jsonElement.EnumerateObject().ToArray();
|
||||
foreach (JsonProperty jsonProperty in jsonProperties)
|
||||
results.Add(jsonProperty.Value.ToString());
|
||||
if (!_AppSettings.IsDevelopment)
|
||||
throw new Exception("Shouldn't expose!");
|
||||
return results.ToArray();
|
||||
List<string> results = _AppSettingsRepository.GetAppSettings();
|
||||
return Ok(results);
|
||||
}
|
||||
|
||||
}
|
@ -1,40 +1,29 @@
|
||||
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
||||
using Expose.MyIT.Shared.Models.Stateless;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Expose.MyIT.Server.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class ClientSettingsController : ControllerBase, IClientSettingsController
|
||||
[Route("api/[controller]")]
|
||||
public class ClientSettingsController : ControllerBase, IClientSettingsController<ActionResult>
|
||||
{
|
||||
|
||||
private readonly Models.AppSettings _AppSettings;
|
||||
private readonly IClientSettingsRepository _ClientSettingsRepository;
|
||||
|
||||
public ClientSettingsController(Models.AppSettings appSettings) => _AppSettings = appSettings;
|
||||
public ClientSettingsController(IClientSettingsRepository clientSettingsRepository) => _ClientSettingsRepository = clientSettingsRepository;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[HttpGet]
|
||||
public string[] GetClientSettings()
|
||||
[HttpGet(nameof(IClientSettingsController<ActionResult>.Action.Client))]
|
||||
public ActionResult GetClientSettings()
|
||||
{
|
||||
List<string> results = new();
|
||||
string? remoteIpAddress = Request.HttpContext.Connection?.RemoteIpAddress?.ToString();
|
||||
if (!string.IsNullOrEmpty(remoteIpAddress))
|
||||
results.Add(remoteIpAddress);
|
||||
else
|
||||
results.Add(nameof(remoteIpAddress));
|
||||
if (!_AppSettings.IsDevelopment)
|
||||
throw new Exception("Shouldn't expose!");
|
||||
return results.ToArray();
|
||||
List<string> results = _ClientSettingsRepository.GetClientSettings(Request.HttpContext.Connection?.RemoteIpAddress);
|
||||
return Ok(results);
|
||||
}
|
||||
|
||||
[Route("api/[controller]/IpAddress")]
|
||||
[HttpGet]
|
||||
public string GetIpAddress()
|
||||
[HttpGet(nameof(IClientSettingsController<ActionResult>.Action.IP))]
|
||||
public ActionResult GetIpAddress()
|
||||
{
|
||||
string? result;
|
||||
result = Request.HttpContext.Connection?.RemoteIpAddress?.ToString();
|
||||
if (string.IsNullOrEmpty(result))
|
||||
result = string.Empty;
|
||||
return result;
|
||||
string result = _ClientSettingsRepository.GetIpAddress(Request.HttpContext.Connection?.RemoteIpAddress);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
}
|
@ -1,33 +1,23 @@
|
||||
using Expose.MyIT.Shared.Models.Methods;
|
||||
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
||||
using Expose.MyIT.Shared.Models.Stateless;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Expose.MyIT.Server.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class ServiceShopOrderController : ControllerBase, IServiceShopOrderController
|
||||
public class ServiceShopOrderController : ControllerBase, IServiceShopOrderController<ActionResult>
|
||||
{
|
||||
|
||||
private readonly IServiceShopOrderController _ServiceShopOrderController;
|
||||
private readonly IServiceShopOrderRepository _ServiceShopOrderRepository;
|
||||
|
||||
public ServiceShopOrderController(IServiceShopOrderRepository ServiceShopOrderRepository)
|
||||
{
|
||||
_ServiceShopOrderController = this;
|
||||
_ServiceShopOrderRepository = ServiceShopOrderRepository;
|
||||
}
|
||||
public ServiceShopOrderController(IServiceShopOrderRepository ServiceShopOrderRepository) => _ServiceShopOrderRepository = ServiceShopOrderRepository;
|
||||
|
||||
async Task<Shared.ViewModels.ServiceShopOrder[]> IServiceShopOrderController.GetAllServiceShopOrders() => await _ServiceShopOrderRepository.GetAllServiceShopOrders();
|
||||
|
||||
async Task<Shared.ViewModels.ServiceShopOrder[]> IServiceShopOrderController.GetServiceShopOrders(string id) => await _ServiceShopOrderRepository.GetServiceShopOrders(id);
|
||||
|
||||
[HttpGet(nameof(Shared.Models.Stateless.IServiceShopOrderController.Action.All))]
|
||||
[HttpGet(nameof(IServiceShopOrderController<ActionResult>.Action.All))]
|
||||
public async Task<ActionResult> GetAllServiceShopOrders()
|
||||
{
|
||||
try
|
||||
{
|
||||
Shared.ViewModels.ServiceShopOrder[] results = await _ServiceShopOrderController.GetAllServiceShopOrders();
|
||||
Shared.ViewModels.ServiceShopOrder[] results = await _ServiceShopOrderRepository.GetAllServiceShopOrders();
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception)
|
||||
@ -43,7 +33,7 @@ public class ServiceShopOrderController : ControllerBase, IServiceShopOrderContr
|
||||
{
|
||||
try
|
||||
{
|
||||
Shared.ViewModels.ServiceShopOrder[] results = await _ServiceShopOrderController.GetServiceShopOrders(id);
|
||||
Shared.ViewModels.ServiceShopOrder[] results = await _ServiceShopOrderRepository.GetServiceShopOrders(id);
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception)
|
||||
|
@ -1,33 +1,23 @@
|
||||
using Expose.MyIT.Shared.Models.Methods;
|
||||
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
||||
using Expose.MyIT.Shared.Models.Stateless;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Expose.MyIT.Server.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class SsaOrderController : ControllerBase, ISsaOrderController
|
||||
public class SsaOrderController : ControllerBase, ISsaOrderController<ActionResult>
|
||||
{
|
||||
|
||||
private readonly ISsaOrderController _SsaOrderController;
|
||||
private readonly ISsaOrderRepository _SsaOrderRepository;
|
||||
|
||||
public SsaOrderController(ISsaOrderRepository SsaOrderRepository)
|
||||
{
|
||||
_SsaOrderController = this;
|
||||
_SsaOrderRepository = SsaOrderRepository;
|
||||
}
|
||||
public SsaOrderController(ISsaOrderRepository SsaOrderRepository) => _SsaOrderRepository = SsaOrderRepository;
|
||||
|
||||
async Task<Shared.ViewModels.SsaOrder[]> ISsaOrderController.GetAllSsaOrders() => await _SsaOrderRepository.GetAllSsaOrders();
|
||||
|
||||
async Task<Shared.ViewModels.SsaOrder[]> ISsaOrderController.GetSsaOrders(string id) => await _SsaOrderRepository.GetSsaOrders(id);
|
||||
|
||||
[HttpGet(nameof(Shared.Models.Stateless.ISsaOrderController.Action.All))]
|
||||
[HttpGet(nameof(ISsaOrderController<ActionResult>.Action.All))]
|
||||
public async Task<ActionResult> GetAllSsaOrders()
|
||||
{
|
||||
try
|
||||
{
|
||||
Shared.ViewModels.SsaOrder[] results = await _SsaOrderController.GetAllSsaOrders();
|
||||
Shared.ViewModels.SsaOrder[] results = await _SsaOrderRepository.GetAllSsaOrders();
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception)
|
||||
@ -43,7 +33,7 @@ public class SsaOrderController : ControllerBase, ISsaOrderController
|
||||
{
|
||||
try
|
||||
{
|
||||
Shared.ViewModels.SsaOrder[] results = await _SsaOrderController.GetSsaOrders(id);
|
||||
Shared.ViewModels.SsaOrder[] results = await _SsaOrderRepository.GetSsaOrders(id);
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception)
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
||||
using Expose.MyIT.Shared.Models.Stateless;
|
||||
using Expose.MyIT.Shared.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@ -7,7 +7,7 @@ namespace Expose.MyIT.Server.Controllers;
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
[Route("api/[controller]")]
|
||||
public class WeatherForecastController : ControllerBase, IWeatherForecastController
|
||||
public class WeatherForecastController : ControllerBase, IWeatherForecastController<WeatherForecast[]>
|
||||
{
|
||||
private static readonly string[] _Summaries = new[]
|
||||
{
|
||||
@ -18,8 +18,6 @@ public class WeatherForecastController : ControllerBase, IWeatherForecastControl
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger) => _Logger = logger;
|
||||
|
||||
Task<WeatherForecast[]> IWeatherForecastController.Get() => throw new NotImplementedException();
|
||||
|
||||
[HttpGet]
|
||||
public WeatherForecast[] Get()
|
||||
{
|
||||
|
Reference in New Issue
Block a user