示例#1
0
        public async Task <List <VendorReportsDto> > GetVendorReportAsync(VendorReportModel model)
        {
            List <VendorReportsDto> vendorReportsList;

            if (model.VendorId == 0)
            {
                vendorReportsList = await(from v in _dataContext.Vendors
                                          select new VendorReportsDto
                {
                    VendorId   = v.Id,
                    VendorName = v.Name

                                 /*TotalAmount = model.TotalAmount,
                                  * TotalPaidAmount = model.TotalPaidAmount*/
                }).ToListAsync();
            }
            else
            {
                vendorReportsList = await(from v in _dataContext.Vendors
                                          where v.Id == model.VendorId
                                          select new VendorReportsDto
                {
                    VendorId   = v.Id,
                    VendorName = v.Name

                                 /*  TotalAmount = model.TotalAmount,
                                  * TotalPaidAmount = model.TotalPaidAmount*/
                }).ToListAsync();
            }

            foreach (var item in vendorReportsList)
            {
                List <BillSummaryDto> billSummaryDtosList = await(from b in _dataContext.Bills
                                                                  where b.VendorId == item.VendorId && b.Status != Constants.BillStatus.Deleted
                                                                  select new BillSummaryDto
                {
                    TotalAmount = b.TotalAmount,
                    status      = b.Status,
                    BillDate    = b.BillDate
                }).ToListAsync();

                billSummaryDtosList = billSummaryDtosList.Where(p => (p.BillDate >= model.StartDate && p.BillDate <= model.EndDate)).ToList();

                item.TotalAmount     = billSummaryDtosList.Sum(x => x.TotalAmount);
                item.TotalPaidAmount = billSummaryDtosList.Where(x => x.status == Constants.BillStatus.Paid).Sum(x => x.TotalAmount);
            }

            return(vendorReportsList);
        }
        public async Task <VendorDetailsReportDto> GetVendorReportAsync(VendorReportModel model)
        {
            var pagedResult = await _reportManager.GetVendorReportAsync(model);

            return(pagedResult);
        }