Creation
This commit is contained in:
30
Server/Controllers/AppSettingsController.cs
Normal file
30
Server/Controllers/AppSettingsController.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Expose.MyIT.Server.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class AppSettingsController : ControllerBase, IAppSettingsController
|
||||
{
|
||||
|
||||
private readonly Models.AppSettings _AppSettings;
|
||||
|
||||
public AppSettingsController(Models.AppSettings appSettings) => _AppSettings = appSettings;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[HttpGet]
|
||||
public string[] 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();
|
||||
}
|
||||
|
||||
}
|
40
Server/Controllers/ClientSettingsController.cs
Normal file
40
Server/Controllers/ClientSettingsController.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Expose.MyIT.Server.Controllers;
|
||||
|
||||
[ApiController]
|
||||
public class ClientSettingsController : ControllerBase, IClientSettingsController
|
||||
{
|
||||
|
||||
private readonly Models.AppSettings _AppSettings;
|
||||
|
||||
public ClientSettingsController(Models.AppSettings appSettings) => _AppSettings = appSettings;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[HttpGet]
|
||||
public string[] 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();
|
||||
}
|
||||
|
||||
[Route("api/[controller]/IpAddress")]
|
||||
[HttpGet]
|
||||
public string GetIpAddress()
|
||||
{
|
||||
string? result;
|
||||
result = Request.HttpContext.Connection?.RemoteIpAddress?.ToString();
|
||||
if (string.IsNullOrEmpty(result))
|
||||
result = string.Empty;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
56
Server/Controllers/ServiceShopOrderController.cs
Normal file
56
Server/Controllers/ServiceShopOrderController.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using Expose.MyIT.Shared.Models.Methods;
|
||||
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Expose.MyIT.Server.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class ServiceShopOrderController : ControllerBase, IServiceShopOrderController
|
||||
{
|
||||
|
||||
private readonly IServiceShopOrderController _ServiceShopOrderController;
|
||||
private readonly IServiceShopOrderRepository _ServiceShopOrderRepository;
|
||||
|
||||
public ServiceShopOrderController(IServiceShopOrderRepository ServiceShopOrderRepository)
|
||||
{
|
||||
_ServiceShopOrderController = this;
|
||||
_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))]
|
||||
public async Task<ActionResult> GetAllServiceShopOrders()
|
||||
{
|
||||
try
|
||||
{
|
||||
Shared.ViewModels.ServiceShopOrder[] results = await _ServiceShopOrderController.GetAllServiceShopOrders();
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError,
|
||||
"Error retrieving data from the database");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<ActionResult> GetServiceShopOrders(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
Shared.ViewModels.ServiceShopOrder[] results = await _ServiceShopOrderController.GetServiceShopOrders(id);
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError,
|
||||
"Error retrieving data from the database");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
56
Server/Controllers/SsaOrderController.cs
Normal file
56
Server/Controllers/SsaOrderController.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using Expose.MyIT.Shared.Models.Methods;
|
||||
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Expose.MyIT.Server.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class SsaOrderController : ControllerBase, ISsaOrderController
|
||||
{
|
||||
|
||||
private readonly ISsaOrderController _SsaOrderController;
|
||||
private readonly ISsaOrderRepository _SsaOrderRepository;
|
||||
|
||||
public SsaOrderController(ISsaOrderRepository SsaOrderRepository)
|
||||
{
|
||||
_SsaOrderController = this;
|
||||
_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))]
|
||||
public async Task<ActionResult> GetAllSsaOrders()
|
||||
{
|
||||
try
|
||||
{
|
||||
Shared.ViewModels.SsaOrder[] results = await _SsaOrderController.GetAllSsaOrders();
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError,
|
||||
"Error retrieving data from the database");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<ActionResult> GetSsaOrders(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
Shared.ViewModels.SsaOrder[] results = await _SsaOrderController.GetSsaOrders(id);
|
||||
return Ok(results);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError,
|
||||
"Error retrieving data from the database");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
36
Server/Controllers/WeatherForecastController.cs
Normal file
36
Server/Controllers/WeatherForecastController.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using Expose.MyIT.Shared.Models.Stateless.Methods;
|
||||
using Expose.MyIT.Shared.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Expose.MyIT.Server.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
[Route("api/[controller]")]
|
||||
public class WeatherForecastController : ControllerBase, IWeatherForecastController
|
||||
{
|
||||
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;
|
||||
|
||||
Task<WeatherForecast[]> IWeatherForecastController.Get() => throw new NotImplementedException();
|
||||
|
||||
[HttpGet]
|
||||
public WeatherForecast[] Get()
|
||||
{
|
||||
_Logger.LogDebug("I was here :)");
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast(new Shared.Models.WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = _Summaries[Random.Shared.Next(_Summaries.Length)]
|
||||
}))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user