using MMBLL.Shift; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.Shift { public class GetShift : BaseEndpoint> { private readonly IShiftBLL _ShiftBLL; public GetShift(IShiftBLL ShiftBLL) { _ShiftBLL = ShiftBLL; } public override void Configure() { Get("/Shift/GetShift"); AllowAnonymous(); } public record GetShiftParameters( [property: FromHeader] string Login, [property: QueryParam] int ShiftId ); //protected override string? GetCacheKey(GetShiftParameters Parameters, LoginDTO LoginDTO) //{ // try // { // return KeyGenerator.KeyGeneration(Parameters.ShiftId!, EntityConstant.OBJECTSHIFT, CacheKeyLevel.USER_LEVEL, LoginDTO); // } // catch (Exception) // { // throw; // } //} protected override async Task> ExecuteAsync(GetShiftParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _ShiftBLL.GetShift(req.ShiftId, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result,CacheKeyLevel.USER_LEVEL,LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex,CacheKeyLevel.USER_LEVEL,LoginDTO,ex.Message,500); } } } }