using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using AdminBLL.IceData; using AdminDAL.DTO.IceData; using static GB5Shared.GB5Constant.Constant; namespace AdminSL.EndPoints.IceData { public class UpdateIceData : BaseEndpoint { private readonly IIceDataBLL _IceDataBLL; public UpdateIceData(IIceDataBLL IceDataBLL) { _IceDataBLL = IceDataBLL; } public override void Configure() { Put("/IceData/UpdateIceData"); AllowAnonymous(); } public record UpdateIceDataParameters( [property: FromBody] IceDataDTO IceDataDTO, [property: FromHeader] string Login ); protected override async Task> ExecuteAsync( UpdateIceDataParameters parameters, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _IceDataBLL.UpdateIceData(parameters.IceDataDTO, 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); } } } }