using AdminBLL.Allocation; using AdminDAL.DTO.Allocation; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AdminSL.EndPoints.Allocation { public class SaveAllocation : BaseEndpoint> { private readonly IAllocationBLL _AllocationBLL; public SaveAllocation(IAllocationBLL AllocationBLL) { _AllocationBLL = AllocationBLL; } public override void Configure() { Post("/Allocation/SaveAllocation"); AllowAnonymous(); } public record SaveAllocationParameters( [property: FromHeader] string Login, [property: FromBody] MAllocationDTO MAllocationDTO ); protected override async Task> ExecuteAsync(SaveAllocationParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _AllocationBLL.SaveAllocation(req.MAllocationDTO, 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); } } } }