using ComplianceBLL.GSTInward; using ComplianceDAL.DTO.GSTInward; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace ComplianceSL.Endpoints.GSTInward; public class SyncFromPortal : BaseEndpoint> { private readonly IGSTInwardBLL _bll; public SyncFromPortal(IGSTInwardBLL bll) => _bll = bll; public override void Configure() { Post("/GSTInward/SyncFromPortal"); AllowAnonymous(); } public record SyncFromPortalParameters( [property: FromHeader] string Login, [property: FromHeader] string? GSTHeader, [property: FromBody] SyncFromPortalRequestDTO Request ); protected override string? GetCacheKey(SyncFromPortalParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync(SyncFromPortalParameters req, LoginDTO login, CancellationToken ct) { try { var header = GSTHeaderParser.Parse(req.GSTHeader); var result = await _bll.SyncFromPortalAsync(req.Request, header, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, login, ex.Message, 500); } } }