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 GetGSTInwardList : BaseEndpoint> { private readonly IGSTInwardBLL _bll; public GetGSTInwardList(IGSTInwardBLL bll) => _bll = bll; public override void Configure() { Get("/GSTInward/GetGSTInwardList"); AllowAnonymous(); } public record GetGSTInwardListParameters( [property: FromHeader] string Login, [property: QueryParam] string OurGSTIN, [property: QueryParam] string ReturnPeriod, [property: QueryParam] string SupplierGSTIN = "", [property: QueryParam] string Source = "", [property: QueryParam] string AcceptanceStatus = "", [property: QueryParam] int Page = 1, [property: QueryParam] int PageSize = 50 ); protected override string? GetCacheKey(GetGSTInwardListParameters req, LoginDTO login) => $"GSTINWARD:LIST:{login.ClientId}:{req.OurGSTIN}:{req.ReturnPeriod}:{req.Source}:{req.AcceptanceStatus}:{req.Page}"; protected override async Task> ExecuteAsync(GetGSTInwardListParameters req, LoginDTO login, CancellationToken ct) { try { var filter = new GSTInwardFilterDTO { OurGSTIN = req.OurGSTIN, ReturnPeriod = req.ReturnPeriod, SupplierGSTIN = req.SupplierGSTIN, Source = req.Source, AcceptanceStatus = req.AcceptanceStatus, Page = req.Page, PageSize = req.PageSize }; var result = await _bll.GetGSTInwardListAsync(filter, 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); } } }