public async Task <JqDataTableResponse <InvoicePaymentListItemDto> > GetPagedResultAsync(InvoiceJqDataTableRequestModel model)
        {
            if (model.Length == 0)
            {
                model.Length = Constants.DefaultPageSize;
            }

            var linqstmt = (from ip in _dataContext.InvoicePayments
                            join i in _dataContext.Invoices
                            on ip.InvoiceId equals i.Id
                            join c in _dataContext.Customers
                            on i.CustomerId equals c.Id
                            where (model.CustomerId == null ||
                                   i.CustomerId == model.CustomerId.Value) &&
                            (model.FilterKey == null ||
                             EF.Functions.Like(i.Id.ToString(), "%" + model.FilterKey + "%") ||
                             EF.Functions.Like(c.FirstName, "%" + model.FilterKey + "%") ||
                             EF.Functions.Like(c.LastName, "%" + model.FilterKey + "%")) &&
                            i.Status != Constants.InvoiceStatus.Deleted
                            select new InvoicePaymentListItemDto
            {
                Id = ip.Id,
                InvoiceNumber = ip.Invoice.Id.ToString(),
                FirstName = c.FirstName,
                MiddleName = c.MiddleName,
                LastName = c.LastName,
                DepositFrom = ip.DepositFrom,
                DepositTo = ip.BankAccount.AccountNumber,
                PaymentMode = ip.PaymentMode,
                Amount = ip.Amount,
                CreatedOn = ip.CreatedOn
            })
                           .AsNoTracking();

            var sortExpression = model.GetSortExpression();

            var pageResult = new JqDataTableResponse <InvoicePaymentListItemDto>
            {
                RecordsTotal    = await _dataContext.InvoicePayments.CountAsync(x => x.Status != Constants.RecordStatus.Deleted),
                RecordsFiltered = await linqstmt.CountAsync(),
                Data            = await linqstmt.OrderBy(sortExpression).ToListAsync()
            };

            return(pageResult);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetTopFiveInvoices(InvoiceJqDataTableRequestModel model)
        {
            var pagedResult = await _invoiceManager.GetTopFiveInvoicesAsync(model);

            return(Ok(pagedResult));
        }
Ejemplo n.º 3
0
 public async Task <JqDataTableResponse <InvoiceListItemDto> > GetTopFiveInvoicesAsync(InvoiceJqDataTableRequestModel model)
 {
     return(await _invoiceRepository.GetTopFiveInvoicesAsync(model));
 }
Ejemplo n.º 4
0
 public async Task <IActionResult> PagedResult(InvoiceJqDataTableRequestModel model)
 {
     return(Ok(await _invoicePaymentManager.GetPagedResultAsync(model)));
 }
Ejemplo n.º 5
0
        public async Task <JqDataTableResponse <InvoiceListItemDto> > GetTopFiveInvoicesAsync(InvoiceJqDataTableRequestModel model)
        {
            if (model.Length == 0)
            {
                model.Length = Constants.DefaultPageSize;
            }
            model.Order[0].Dir    = "desc";
            model.Order[0].Column = 4;
            var linqstmt = (from i in _dataContext.Invoices
                            join c in _dataContext.Customers
                            on i.CustomerId equals c.Id
                            where (model.CustomerId == null ||
                                   i.CustomerId == model.CustomerId.Value) &&
                            (model.FilterKey == null ||
                             EF.Functions.Like(c.FirstName, "%" + model.FilterKey + "%") ||
                             EF.Functions.Like(c.LastName, "%" + model.FilterKey + "%")) &&
                            i.Status != Constants.InvoiceStatus.Deleted
                            select new InvoiceListItemDto
            {
                Id = i.Id,
                CustomerId = i.CustomerId,
                CustomerName = (c.FirstName ?? "") + " " + (c.MiddleName ?? "") + " " + (c.LastName ?? ""),
                Description = i.Remark,
                Amount = i.Services.Sum(x => x.Rate),
                Discount = i.Discount,
                Tax = i.Tax,
                TotalAmount = i.TotalAmount,
                CreatedOn = i.CreatedOn,
                Status = i.Status,
                InvoiceNumber = i.InvoiceNumber,
                SubTotal = i.SubTotal
            })
                           .AsNoTracking().Take(5);

            var sortExpresstion = model.GetSortExpression();

            var pagedResult = new JqDataTableResponse <InvoiceListItemDto>
            {
                RecordsTotal    = await _dataContext.Invoices.CountAsync(x => model.CustomerId == null || x.CustomerId == model.CustomerId.Value),
                RecordsFiltered = await linqstmt.CountAsync(),
                Data            = await linqstmt.OrderBy(sortExpresstion).Skip(model.Start).Take(model.Length).ToListAsync()
            };

            foreach (var invoiceListItemDto in pagedResult.Data)
            {
                invoiceListItemDto.CreatedOn = Utility.GetDateTime(invoiceListItemDto.CreatedOn, null);
            }

            return(pagedResult);
        }
 public async Task <JqDataTableResponse <InvoicePaymentListItemDto> > GetPagedResultAsync(InvoiceJqDataTableRequestModel model)
 {
     return(await _invoicePaymentRepository.GetPagedResultAsync(model));
 }