public ShippingRevenueSummaryListModel Create(IEnumerable <Event> events, IEnumerable <Host> hosts, IEnumerable <Pod> pods, IEnumerable <OrderedPair <long, int> > eventIdShippingCountPairs, IEnumerable <OrderedPair <long, decimal> > eventIdShippingRevenuePairs) { var model = new ShippingRevenueSummaryListModel(); var shippingRevenueSummaryModels = new List <ShippingRevenueSummaryViewModel>(); events.ToList().ForEach(e => { var host = hosts.Where(h => h.Id == e.HostId).FirstOrDefault(); var eventPods = pods.Where(p => e.PodIds.Contains(p.Id)).ToList(); var shippingCount = eventIdShippingCountPairs.Where(sc => sc.FirstValue == e.Id).Select(sc => sc.SecondValue).FirstOrDefault(); var shippingRevenue = eventIdShippingRevenuePairs.Where(sc => sc.FirstValue == e.Id).Select(sc => sc.SecondValue).FirstOrDefault(); shippingRevenueSummaryModels.Add(new ShippingRevenueSummaryViewModel { EventId = e.Id, EventDate = e.EventDate, EventName = host.OrganizationName, EventAddress = Mapper.Map <Address, AddressViewModel>(host.Address), Vehicle = string.Join(", ", eventPods.Select(ep => ep.Name)), ShippingCount = shippingCount, Revenue = shippingRevenue, }); }); model.Collection = shippingRevenueSummaryModels; return(model); }
public ActionResult ShippingRevenueSummary(ShippingRevenueListModelFilter filter = null, int pageNumber = 1) { int totalRecords = 0; var model = _financeReportingService.GetShippingRevenueSummary(pageNumber, _pageSize, filter, out totalRecords); if (model == null) { model = new ShippingRevenueSummaryListModel(); } if (filter == null) { filter = new ShippingRevenueListModelFilter { FromDate = DateTime.Now, ToDate = DateTime.Now } } ; if (!filter.FromDate.HasValue && !filter.ToDate.HasValue && filter.PodId <= 0 && filter.EventId <= 0) { filter.FromDate = DateTime.Now; filter.ToDate = DateTime.Now; } model.Filter = filter; var currentAction = ControllerContext.RouteData.Values["action"].ToString(); Func <int, string> urlFunc = pn => Url.Action(currentAction, new { pageNumber = pn, filter.EventId, filter.FromDate, filter.ToDate, filter.PodId, }); model.PagingModel = new PagingModel(pageNumber, _pageSize, totalRecords, urlFunc); return(View(model)); }