Beispiel #1
0
        public CustomerUpsellListModel Create(IEnumerable <Order> orders, IEnumerable <EventBasicInfoViewModel> eventListModel, IEnumerable <Customer> customers, IEnumerable <OrderedPair <long, string> > packages,
                                              IEnumerable <OrderedPair <long, string> > tests, IEnumerable <OrderedPair <long, string> > products, IEnumerable <OrderedPair <long, string> > agents)
        {
            var model = new CustomerUpsellListModel();
            var customerUpsellModels = new List <CustomerUpsellModel>();

            orders.ToList().ForEach(o =>
            {
                var customer = customers.FirstOrDefault(c => c.CustomerId == o.CustomerId);

                var eventModel = eventListModel.FirstOrDefault(e => e.Id == o.EventId.Value);

                var eventCustomer = new CustomerUpsellModel
                {
                    CustomerId   = customer.CustomerId,
                    CustomerCode = customer.CustomerId,
                    EventDate    = eventModel.EventDate,
                    Name         = customer.Name,
                    Pod          = eventModel.PodNames()
                };

                Associate(eventCustomer, o, packages, tests, products, agents);

                customerUpsellModels.Add(eventCustomer);
            });

            model.Collection = customerUpsellModels;
            return(model);
        }
Beispiel #2
0
        public ActionResult Upsell(CustomerUpsellListModelFilter filter = null, int pageNumber = 1)
        {
            if (!filter.FromDate.HasValue && !filter.ToDate.HasValue)
            {
                filter.FromDate = DateTime.Now.AddMonths(-1).Date;
                filter.ToDate   = DateTime.Now.Date;
            }
            int totalRecords = 0;
            var model        = _financeReportingService.GetCustomerUpsellModel(pageNumber, _pageSize, filter, out totalRecords);

            if (model == null)
            {
                model = new CustomerUpsellListModel();
            }
            model.Filter = filter;

            var currentAction          = ControllerContext.RouteData.Values["action"].ToString();
            Func <int, string> urlFunc =
                pn => Url.Action(currentAction, new { pageNumber = pn, filter.FromDate, filter.ToDate, filter.Vehicle, filter.ZipCode, filter.Territory, filter.UpSellRole, filter.CorporateAccountId });

            model.PagingModel = new PagingModel(pageNumber, _pageSize, totalRecords, urlFunc);

            return(View(model));
        }