using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.StockAccountPost; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.StockValuation { public class PostToGL : BaseEndpoint> { private readonly IStockAccountPostBLL _bll; public PostToGL(IStockAccountPostBLL bll) { _bll = bll; } public override void Configure() { Post("/StockValuation/PostToGL"); AllowAnonymous(); } public record PostToGLParameters( [property: FromHeader] string Login, [property: QueryParam] int ObjectTypeId, [property: QueryParam] int ObjectId, [property: QueryParam] int OUID, [property: QueryParam] bool IsTransfer ); protected override string? GetCacheKey(PostToGLParameters Parameters, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync( PostToGLParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _bll.PostToGLAsync( req.ObjectTypeId, req.ObjectId, req.OUID, req.IsTransfer, 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); } } } }