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