using MMBLL.Shift; using MMDAL.DTO.Shift; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using FastEndpoints; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.Shift { public class SaveShift : BaseEndpoint> { private readonly IShiftBLL _ShiftBLL; public SaveShift(IShiftBLL ShiftBLL) { _ShiftBLL = ShiftBLL; } public override void Configure() { Post("/Shift/SaveShift"); AllowAnonymous(); } public record SaveShiftParameters( [property: FromHeader] string Login, [property: FromBody] ShiftDTO ShiftDTO ); protected override async Task> ExecuteAsync(SaveShiftParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _ShiftBLL.SaveShift(req.ShiftDTO, 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); } } } }