using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MaintenanceBLL.KeyComponent; using MaintenanceDAL.DTO.KeyComponent; using static GB5Shared.GB5Constant.Constant; namespace MaintenanceSL.FastEndPoints.KeyComponent { public class SaveKeyComponent : BaseEndpoint { private readonly IKeyComponentBLL _KeyComponentBLL; public SaveKeyComponent(IKeyComponentBLL KeyComponentBLL) { _KeyComponentBLL = KeyComponentBLL; } public override void Configure() { Post("/KeyComponent/SaveKeyComponent"); AllowAnonymous(); } public record SaveKeyComponentParameters( [property: FromBody] KeyComponentDTO KeyComponentDTO, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync(SaveKeyComponentParameters parameters,LoginDTO LoginDTO,CancellationToken ct) { try { var result = await _KeyComponentBLL.SaveKeyComponent(parameters.KeyComponentDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }