Esempio n. 1
0
        public async Task <JqDataTableResponse <QuotationListItemDto> > GetPagedResultAsync(QuotationJqDataTableRequestModel model)
        {
            if (model.Length == 0)
            {
                model.Length = Constants.DefaultPageSize;
            }

            var linqstmt = (from i in _dataContext.Quotations
                            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 + "%") ||
                             EF.Functions.Like(c.MiddleName, "%" + model.FilterKey + "%") ||
                             EF.Functions.Like(i.QuotationNumber, "%" + model.FilterKey + "%")) &&
                            i.Status != Constants.InvoiceStatus.Deleted
                            select new QuotationListItemDto
            {
                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,
                QuotationDate = i.QuotationDate,
                StrQuotationDate = i.StrQuotationDate,
                ExpiryDate = i.ExpireDate,
                StrExpiryDate = i.StrExpireDate,
                QuotationNumber = i.QuotationNumber,
                SubTotal = i.SubTotal
            })
                           .AsNoTracking();

            var sortExpresstion = model.GetSortExpression();

            var pagedResult = new JqDataTableResponse <QuotationListItemDto>
            {
                RecordsTotal    = await _dataContext.Quotations.CountAsync(x => x.Status != Constants.InvoiceStatus.Deleted),
                RecordsFiltered = await linqstmt.CountAsync(),
                Data            = await linqstmt.OrderBy(sortExpresstion).Skip(model.Start).Take(model.Length).ToListAsync()
            };

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

            return(pagedResult);
        }
 public async Task <JqDataTableResponse <QuotationListItemDto> > GetPagedResultAsync(QuotationJqDataTableRequestModel model)
 {
     return(await _quotationRepository.GetPagedResultAsync(model));
 }
Esempio n. 3
0
        public async Task <IActionResult> GetPagedResult(QuotationJqDataTableRequestModel model)
        {
            var pagedResult = await _quotationManager.GetPagedResultAsync(model);

            return(Ok(pagedResult));
        }