예제 #1
0
        public ActionResult ShippingRevenueDetail(ShippingRevenueListModelFilter filter = null, int pageNumber = 1)
        {
            int totalRecords = 0;

            var model = _financeReportingService.GetShippingRevenueDetail(pageNumber, _pageSize, filter, out totalRecords);

            if (model == null)
            {
                model = new ShippingRevenueDetailListModel();
            }
            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));
        }
예제 #2
0
        public ShippingRevenueDetailListModel CreateShippingRevenueDetail(IEnumerable <EventCustomer> eventCustomers, IEnumerable <Event> events, IEnumerable <Host> hosts, IEnumerable <Pod> pods, IEnumerable <Customer> customers,
                                                                          IEnumerable <ShippingDetail> shippingDetails, IEnumerable <OrderedPair <long, long> > shippingDetailIdEventCustomerIdPairs, IEnumerable <ShippingOption> shippingOptions, IEnumerable <Order> orders)
        {
            var model = new ShippingRevenueDetailListModel();
            var shippingRevenueDetailModels = new List <ShippingRevenueDetailViewModel>();

            eventCustomers.ToList().ForEach(ec =>
            {
                var eventData         = events.Where(e => e.Id == ec.EventId).First();
                var host              = hosts.Where(h => h.Id == eventData.HostId).First();
                var eventPods         = pods.Where(p => eventData.PodIds.Contains(p.Id)).ToList();
                var customer          = customers.Where(c => c.CustomerId == ec.CustomerId).First();
                var shippingDetailIds = shippingDetailIdEventCustomerIdPairs.Where(sdec => sdec.SecondValue == ec.Id).Select(sdec => sdec.FirstValue).ToArray();

                var customerShippingDetails = shippingDetails.Where(sd => shippingDetailIds.Contains(sd.Id)).Select(sd => sd).ToArray();
                IEnumerable <string> customerShippingOptions = null;
                var shippingCost = 0.0m;
                if (customerShippingDetails.Count() > 0)
                {
                    var shippingoptionIds   = customerShippingDetails.Select(csd => csd.ShippingOption.Id).ToArray();
                    shippingCost            = customerShippingDetails.Sum(sd => sd.ActualPrice);
                    customerShippingOptions = shippingOptions.Where(so => shippingoptionIds.Contains(so.Id)).Select(so => so.Name).ToArray();
                }

                bool isPaid = false;
                var order   = orders.Where(o => o.EventId == ec.EventId && o.CustomerId == ec.CustomerId).FirstOrDefault();
                if (order != null)
                {
                    isPaid = order.TotalAmountPaid >= order.DiscountedTotal;
                }

                shippingRevenueDetailModels.Add(new ShippingRevenueDetailViewModel
                {
                    CustomerId      = customer.CustomerId,
                    CustomerName    = customer.Name,
                    CustomerAddress = Mapper.Map <Address, AddressViewModel>(customer.Address),
                    EventId         = eventData.Id,
                    EventDate       = eventData.EventDate,
                    EventName       = host.OrganizationName,
                    EventAddress    = Mapper.Map <Address, AddressViewModel>(host.Address),
                    Vehicle         = string.Join(", ", eventPods.Select(ep => ep.Name)),
                    ShippingOptions = customerShippingOptions,
                    ShippingCost    = shippingCost,
                    IsPaid          = isPaid ? "Yes" : "No"
                });
            });

            model.Collection = shippingRevenueDetailModels;
            return(model);
        }