using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.ItemModel; using MMDAL.DTO.Model; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.ItemModel { public class SaveItemModel : BaseEndpoint> { private readonly IItemModelBLL _ItemModelBLL; public SaveItemModel(IItemModelBLL ItemModelBLL) { _ItemModelBLL = ItemModelBLL; } public override void Configure() { Post("/ItemModel/SaveItemModel"); AllowAnonymous(); } public record SaveItemModelParameters( [property: FromHeader] string Login, [property: FromBody] ModelDTO ItemModelDTO ); protected override async Task> ExecuteAsync(SaveItemModelParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _ItemModelBLL.SaveItemModel(req.ItemModelDTO, 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); } } } }