Creation
This commit is contained in:
50
Server/Models/AppSettings.cs
Normal file
50
Server/Models/AppSettings.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Expose.MyIT.Server.Models;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
public string BuildNumber { init; get; }
|
||||
public string Company { init; get; }
|
||||
public string ConnectionString { init; get; }
|
||||
public string GitCommitSeven { init; get; }
|
||||
public bool IsDevelopment { init; get; }
|
||||
public bool IsStaging { init; get; }
|
||||
public string MonAResource { init; get; }
|
||||
public string MonASite { init; get; }
|
||||
public string URLs { init; get; }
|
||||
public string WorkingDirectoryName { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public AppSettings(string buildNumber,
|
||||
string company,
|
||||
string connectionString,
|
||||
string gitCommitSeven,
|
||||
bool isDevelopment,
|
||||
bool isStaging,
|
||||
string monAResource,
|
||||
string monASite,
|
||||
string urls,
|
||||
string workingDirectoryName)
|
||||
{
|
||||
BuildNumber = buildNumber;
|
||||
Company = company;
|
||||
ConnectionString = connectionString;
|
||||
GitCommitSeven = gitCommitSeven;
|
||||
IsDevelopment = isDevelopment;
|
||||
IsStaging = isStaging;
|
||||
MonAResource = monAResource;
|
||||
MonASite = monASite;
|
||||
URLs = urls;
|
||||
WorkingDirectoryName = workingDirectoryName;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
77
Server/Models/Binder/AppSettings.cs
Normal file
77
Server/Models/Binder/AppSettings.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Expose.MyIT.Server.Models.Binder;
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
|
||||
#nullable disable
|
||||
|
||||
[Display(Name = "Build Number"), Required] public string BuildNumber { get; set; }
|
||||
[Display(Name = "Company"), Required] public string Company { get; set; }
|
||||
[Display(Name = "Connection String"), Required] public string ConnectionString { get; set; }
|
||||
[Display(Name = "Git Commit Seven"), Required] public string GitCommitSeven { get; set; }
|
||||
[Display(Name = "Is Development"), Required] public bool? IsDevelopment { get; set; }
|
||||
[Display(Name = "Is Staging"), Required] public bool? IsStaging { get; set; }
|
||||
[Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; }
|
||||
[Display(Name = "MonA Site"), Required] public string MonASite { get; set; }
|
||||
[Display(Name = "URLs"), Required] public string URLs { get; set; }
|
||||
[Display(Name = "Working Directory Name"), Required] public string WorkingDirectoryName { get; set; }
|
||||
|
||||
#nullable restore
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Models.AppSettings Get(AppSettings? appSettings)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
if (appSettings is null)
|
||||
throw new NullReferenceException(nameof(appSettings));
|
||||
if (appSettings.BuildNumber is null)
|
||||
throw new NullReferenceException(nameof(BuildNumber));
|
||||
if (appSettings.Company is null)
|
||||
throw new NullReferenceException(nameof(Company));
|
||||
if (appSettings.ConnectionString is null)
|
||||
throw new NullReferenceException(nameof(ConnectionString));
|
||||
if (appSettings.GitCommitSeven is null)
|
||||
throw new NullReferenceException(nameof(GitCommitSeven));
|
||||
if (appSettings.MonAResource is null)
|
||||
throw new NullReferenceException(nameof(MonAResource));
|
||||
if (appSettings.IsDevelopment is null)
|
||||
throw new NullReferenceException(nameof(IsDevelopment));
|
||||
if (appSettings.IsStaging is null)
|
||||
throw new NullReferenceException(nameof(IsStaging));
|
||||
if (appSettings.MonASite is null)
|
||||
throw new NullReferenceException(nameof(MonASite));
|
||||
if (appSettings.URLs is null)
|
||||
throw new NullReferenceException(nameof(URLs));
|
||||
if (appSettings.WorkingDirectoryName is null)
|
||||
throw new NullReferenceException(nameof(WorkingDirectoryName));
|
||||
result = new(
|
||||
appSettings.BuildNumber,
|
||||
appSettings.Company,
|
||||
appSettings.ConnectionString,
|
||||
appSettings.GitCommitSeven,
|
||||
appSettings.IsDevelopment.Value,
|
||||
appSettings.IsStaging.Value,
|
||||
appSettings.MonAResource,
|
||||
appSettings.MonASite,
|
||||
appSettings.URLs,
|
||||
appSettings.WorkingDirectoryName);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Models.AppSettings Get(IConfigurationRoot configurationRoot)
|
||||
{
|
||||
Models.AppSettings result;
|
||||
AppSettings? appSettings = configurationRoot.Get<AppSettings>();
|
||||
result = Get(appSettings);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
51
Server/Models/ServiceShopOrderRepository.cs
Normal file
51
Server/Models/ServiceShopOrderRepository.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using Expose.MyIT.Shared.Models.Methods;
|
||||
using Expose.MyIT.Shared.ViewModels;
|
||||
using Serilog.Context;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Expose.MyIT.Server.Models;
|
||||
|
||||
public class ServiceShopOrderRepository : IServiceShopOrderRepository
|
||||
{
|
||||
|
||||
private readonly Serilog.ILogger _Log;
|
||||
|
||||
public ServiceShopOrderRepository() => _Log = Serilog.Log.ForContext<ServiceShopOrderRepository>();
|
||||
|
||||
private static ServiceShopOrder[] GetServiceShopOrders(Shared.Models.ServiceShop? ServiceShop)
|
||||
{
|
||||
ServiceShopOrder[] result = Shared.Models.Stateless.Methods.IServiceShopOrder.GetServiceShopOrders(ServiceShop);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Shared.Models.ServiceShop? GetServiceShopOrders()
|
||||
{
|
||||
Shared.Models.ServiceShop? result;
|
||||
string jsonFile = Path.Combine(AppContext.BaseDirectory, "service-shop.json");
|
||||
string json = File.ReadAllText(jsonFile);
|
||||
result = JsonSerializer.Deserialize<Shared.Models.ServiceShop>(json);
|
||||
return result;
|
||||
}
|
||||
|
||||
async Task<ServiceShopOrder[]> IServiceShopOrderRepository.GetAllServiceShopOrders()
|
||||
{
|
||||
ServiceShopOrder[] results;
|
||||
string? methodName = Shared.Models.Stateless.Methods.IMethodName.GetActualAsyncMethodName();
|
||||
using (LogContext.PushProperty("MethodName", methodName))
|
||||
{
|
||||
_Log.Debug("() => ...");
|
||||
Shared.Models.ServiceShop? ServiceShop = await Task.Run(GetServiceShopOrders);
|
||||
results = GetServiceShopOrders(ServiceShop);
|
||||
}
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
async Task<ServiceShopOrder[]> IServiceShopOrderRepository.GetServiceShopOrders(string id)
|
||||
{
|
||||
ServiceShopOrder[] results;
|
||||
Shared.Models.ServiceShop? ServiceShop = await Task.Run(GetServiceShopOrders);
|
||||
results = GetServiceShopOrders(ServiceShop).Where(l => l.Id == id).ToArray();
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
51
Server/Models/SsaOrderRepository.cs
Normal file
51
Server/Models/SsaOrderRepository.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using Expose.MyIT.Shared.Models.Methods;
|
||||
using Expose.MyIT.Shared.ViewModels;
|
||||
using Serilog.Context;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Expose.MyIT.Server.Models;
|
||||
|
||||
public class SsaOrderRepository : ISsaOrderRepository
|
||||
{
|
||||
|
||||
private readonly Serilog.ILogger _Log;
|
||||
|
||||
public SsaOrderRepository() => _Log = Serilog.Log.ForContext<SsaOrderRepository>();
|
||||
|
||||
private static SsaOrder[] GetSsaOrders(Shared.Models.SSA? ssa)
|
||||
{
|
||||
SsaOrder[] result = Shared.Models.Stateless.Methods.ISsaOrder.GetSsaOrders(ssa);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Shared.Models.SSA? GetSsaOrders()
|
||||
{
|
||||
Shared.Models.SSA? result;
|
||||
string jsonFile = Path.Combine(AppContext.BaseDirectory, "ssa.json");
|
||||
string json = File.ReadAllText(jsonFile);
|
||||
result = JsonSerializer.Deserialize<Shared.Models.SSA>(json);
|
||||
return result;
|
||||
}
|
||||
|
||||
async Task<SsaOrder[]> ISsaOrderRepository.GetAllSsaOrders()
|
||||
{
|
||||
SsaOrder[] results;
|
||||
string? methodName = Shared.Models.Stateless.Methods.IMethodName.GetActualAsyncMethodName();
|
||||
using (LogContext.PushProperty("MethodName", methodName))
|
||||
{
|
||||
_Log.Debug("() => ...");
|
||||
Shared.Models.SSA? ssa = await Task.Run(GetSsaOrders);
|
||||
results = GetSsaOrders(ssa);
|
||||
}
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
async Task<SsaOrder[]> ISsaOrderRepository.GetSsaOrders(string id)
|
||||
{
|
||||
SsaOrder[] results;
|
||||
Shared.Models.SSA? ssa = await Task.Run(GetSsaOrders);
|
||||
results = GetSsaOrders(ssa).Where(l => l.Id == id).ToArray();
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user