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