Beispiel #1
0
        public ActionResult OrderManageList(string num, int?currentTab = 1, int?indexNum = 1, int?pageSize = 4)
        {
            long id = 0;

            if (num != null)
            {
                try
                {
                    id = Convert.ToInt64(num);
                }
                catch (Exception ex)
                {
                    return(Content("<script>alert('请输入正确的订单编号');location.href='/Order/OrderManageList'</script>"));
                }
            }

            PendingDeliveryStatusViewModel pendingDeliveryStatusViewModel = new PendingDeliveryStatusViewModel();
            PendingPaymentStatusViewModel  pendingPaymentStatusViewModel  = new PendingPaymentStatusViewModel();
            PendingCommentStatusViewModel  pendingCommentStatusViewModel  = new PendingCommentStatusViewModel();
            PendingReceivedStatusViewModel pendingReceivedStatusViewModel = new PendingReceivedStatusViewModel();
            AllStatusViewModel             allStatusViewModel             = new AllStatusViewModel();

            #region getPendingPaymentOrderDataModel
            var pendingPaymentOrderDataModel = (from o in _readFromDb.Orders
                                                where o.OrderStatus == Constants.OBLIGATION && (o.Id == id || id == 0)
                                                select new OrderDataModel()
            {
                Id = o.Id,
                AddressId = o.AddressId,
                TotalAmount = o.TotalAmount,
                OrderDate = o.OrderDate,
                OrderStatus = o.OrderStatus,
                DeliveryDate = o.DeliveryDate,
            }).OrderByDescending(x => x.OrderDate).ToPagedList(indexNum, pageSize);
            var pendingPaymentList = pendingPaymentOrderDataModel.ToList();

            List <Order> PendingPaymentList = new List <Order>();
            foreach (OrderDataModel order in pendingPaymentList)
            {
                PendingPaymentList.Add(_readFromDb.Orders.Where(x => x.Id == order.Id).First());
            }
            pendingPaymentStatusViewModel.pageBar    = pendingPaymentOrderDataModel.getPageBar();
            pendingPaymentStatusViewModel.TotalCount = pendingPaymentOrderDataModel.TotalCount;
            pendingPaymentStatusViewModel.TotalPage  = pendingPaymentOrderDataModel.TotalPage;
            pendingPaymentStatusViewModel.PageIndex  = pendingPaymentOrderDataModel.PageIndex;
            #endregion
            #region getPendingDeliveryOrderDataModel
            var pendingDeliveryOrderDataModel = (from o in _readFromDb.Orders
                                                 where o.OrderStatus == Constants.TRANSFER && (o.Id == id || id == 0)
                                                 select new OrderDataModel()
            {
                Id = o.Id,
                AddressId = o.AddressId,
                TotalAmount = o.TotalAmount,
                OrderDate = o.OrderDate,
                OrderStatus = o.OrderStatus,
                DeliveryDate = o.DeliveryDate,
            }).OrderByDescending(x => x.OrderDate).ToPagedList(indexNum, pageSize);
            var pendingDeliveryList = pendingPaymentOrderDataModel.ToList();

            List <Order> PendingDeliveryList = new List <Order>();
            foreach (OrderDataModel order in pendingDeliveryList)
            {
                PendingDeliveryList.Add(_readFromDb.Orders.Where(x => x.Id == order.Id).First());
            }
            pendingDeliveryStatusViewModel.pageBar    = pendingDeliveryOrderDataModel.getPageBar();
            pendingDeliveryStatusViewModel.TotalCount = pendingDeliveryOrderDataModel.TotalCount;
            pendingDeliveryStatusViewModel.TotalPage  = pendingDeliveryOrderDataModel.TotalPage;
            pendingDeliveryStatusViewModel.PageIndex  = pendingDeliveryOrderDataModel.PageIndex;
            #endregion
            #region getPendingReceivedOrderDataModel
            var pendingReceivedOrderDataModel = (from o in _readFromDb.Orders
                                                 where o.OrderStatus == Constants.DELIVERY && (o.Id == id || id == 0)
                                                 select new OrderDataModel()
            {
                Id = o.Id,
                AddressId = o.AddressId,
                TotalAmount = o.TotalAmount,
                OrderDate = o.OrderDate,
                OrderStatus = o.OrderStatus,
                DeliveryDate = o.DeliveryDate,
            }).OrderByDescending(x => x.OrderDate).ToPagedList(indexNum, pageSize);
            var pendingReceivedList = pendingReceivedOrderDataModel.ToList();

            List <Order> PendingReceivedList = new List <Order>();
            foreach (OrderDataModel order in pendingReceivedList)
            {
                PendingReceivedList.Add(_readFromDb.Orders.Where(x => x.Id == order.Id).First());
            }
            pendingReceivedStatusViewModel.pageBar    = pendingReceivedOrderDataModel.getPageBar();
            pendingReceivedStatusViewModel.TotalCount = pendingReceivedOrderDataModel.TotalCount;
            pendingReceivedStatusViewModel.TotalPage  = pendingReceivedOrderDataModel.TotalPage;
            pendingReceivedStatusViewModel.PageIndex  = pendingReceivedOrderDataModel.PageIndex;
            #endregion
            #region getFinishedOrderDataModel
            var finishedOrderDataModel = (from o in _readFromDb.Orders
                                          where o.OrderStatus == Constants.FINISHED && (o.Id == id || id == 0)
                                          select new OrderDataModel()
            {
                Id = o.Id,
                AddressId = o.AddressId,
                TotalAmount = o.TotalAmount,
                OrderDate = o.OrderDate,
                OrderStatus = o.OrderStatus,
                DeliveryDate = o.DeliveryDate,
            }).OrderByDescending(x => x.OrderDate).ToPagedList(indexNum, pageSize);
            var finishedList = finishedOrderDataModel.ToList();

            List <Order> FinishedList = new List <Order>();
            foreach (OrderDataModel order in finishedList)
            {
                FinishedList.Add(_readFromDb.Orders.Where(x => x.Id == order.Id).First());
            }
            pendingCommentStatusViewModel.pageBar    = finishedOrderDataModel.getPageBar();
            pendingCommentStatusViewModel.TotalCount = finishedOrderDataModel.TotalCount;
            pendingCommentStatusViewModel.TotalPage  = finishedOrderDataModel.TotalPage;
            pendingCommentStatusViewModel.PageIndex  = finishedOrderDataModel.PageIndex;
            #endregion
            #region getAllOrderByCustomerId
            var allOrderDataModel = (from o in _readFromDb.Orders
                                     where  (o.Id == id || id == 0)
                                     select new OrderDataModel()
            {
                Id = o.Id,
                AddressId = o.AddressId,
                TotalAmount = o.TotalAmount,
                OrderDate = o.OrderDate,
                OrderStatus = o.OrderStatus,
                DeliveryDate = o.DeliveryDate,
            }).OrderByDescending(x => x.OrderDate).ToPagedList(indexNum, pageSize);
            var allList = allOrderDataModel.ToList();

            List <Order> AllList = new List <Order>();
            foreach (OrderDataModel order in allList)
            {
                AllList.Add(_readFromDb.Orders.Where(x => x.Id == order.Id).First());
            }
            allStatusViewModel.pageBar    = allOrderDataModel.getPageBar();
            allStatusViewModel.TotalCount = allOrderDataModel.TotalCount;
            allStatusViewModel.TotalPage  = allOrderDataModel.TotalPage;
            allStatusViewModel.PageIndex  = allOrderDataModel.PageIndex;
            #endregion
            allStatusViewModel.AllOrder = AllList;
            pendingPaymentStatusViewModel.PendingPaymentOrder   = PendingPaymentList;
            pendingDeliveryStatusViewModel.PendingDeliveryOrder = PendingDeliveryList;
            pendingReceivedStatusViewModel.PendingReceivedOrder = PendingReceivedList;
            pendingCommentStatusViewModel.PendingComment        = FinishedList;

            OrderViewModel orderViewModel = new OrderViewModel();
            orderViewModel.CurrentTab                     = (int)currentTab;
            orderViewModel.AllStatusViewModel             = allStatusViewModel;
            orderViewModel.PendingPaymentStatusViewModel  = pendingPaymentStatusViewModel;
            orderViewModel.PendingDeliveryStatusViewModel = pendingDeliveryStatusViewModel;
            orderViewModel.PendingReceivedStatusViewModel = pendingReceivedStatusViewModel;
            orderViewModel.PendingCommentStatusViewModel  = pendingCommentStatusViewModel;

            return(View("OrderManage", orderViewModel));
        }
Beispiel #2
0
        // GET: Order
        public ActionResult Index(int?currentTab = 1, int?indexNum = 1, int?pageSize = 4)
        {
            Customer customer = Session[Constants.SESSION_USER] as Customer;
            PendingDeliveryStatusViewModel pendingDeliveryStatusViewModel = new PendingDeliveryStatusViewModel();
            PendingPaymentStatusViewModel  pendingPaymentStatusViewModel  = new PendingPaymentStatusViewModel();
            PendingCommentStatusViewModel  pendingCommentStatusViewModel  = new PendingCommentStatusViewModel();
            PendingReceivedStatusViewModel pendingReceivedStatusViewModel = new PendingReceivedStatusViewModel();
            AllStatusViewModel             allStatusViewModel             = new AllStatusViewModel();

            #region getPendingPaymentOrderDataModel
            var pendingPaymentOrderDataModel = (from o in _readFromDb.Orders
                                                where o.CustomerId == customer.Id && o.OrderStatus == Constants.OBLIGATION
                                                select new OrderDataModel()
            {
                Id = o.Id,
                CustomerId = customer.Id,
                AddressId = o.AddressId,
                CustomerName = customer.CustomerName,
                TotalAmount = o.TotalAmount,
                OrderDate = o.OrderDate,
                OrderStatus = o.OrderStatus,
                DeliveryDate = o.DeliveryDate,
            }).OrderByDescending(x => x.OrderDate).ToPagedList(indexNum, pageSize);
            var pendingPaymentList = pendingPaymentOrderDataModel.ToList();

            List <Order> PendingPaymentList = new List <Order>();
            foreach (OrderDataModel order in pendingPaymentList)
            {
                PendingPaymentList.Add(_readFromDb.Orders.Where(x => x.Id == order.Id).First());
            }
            pendingPaymentStatusViewModel.pageBar    = pendingPaymentOrderDataModel.getPageBar();
            pendingPaymentStatusViewModel.TotalCount = pendingPaymentOrderDataModel.TotalCount;
            pendingPaymentStatusViewModel.TotalPage  = pendingPaymentOrderDataModel.TotalPage;
            pendingPaymentStatusViewModel.PageIndex  = pendingPaymentOrderDataModel.PageIndex;
            #endregion
            #region getPendingDeliveryOrderDataModel
            var pendingDeliveryOrderDataModel = (from o in _readFromDb.Orders
                                                 where o.CustomerId == customer.Id && o.OrderStatus == Constants.TRANSFER
                                                 select new OrderDataModel()
            {
                Id = o.Id,
                CustomerId = customer.Id,
                AddressId = o.AddressId,
                CustomerName = customer.CustomerName,
                TotalAmount = o.TotalAmount,
                OrderDate = o.OrderDate,
                OrderStatus = o.OrderStatus,
                DeliveryDate = o.DeliveryDate,
            }).OrderByDescending(x => x.OrderDate).ToPagedList(indexNum, pageSize);
            var pendingDeliveryList = pendingDeliveryOrderDataModel.ToList();

            List <Order> PendingDeliveryList = new List <Order>();
            foreach (OrderDataModel order in pendingDeliveryList)
            {
                PendingDeliveryList.Add(_readFromDb.Orders.Where(x => x.Id == order.Id).First());
            }
            pendingDeliveryStatusViewModel.pageBar    = pendingDeliveryOrderDataModel.getPageBar();
            pendingDeliveryStatusViewModel.TotalCount = pendingDeliveryOrderDataModel.TotalCount;
            pendingDeliveryStatusViewModel.TotalPage  = pendingDeliveryOrderDataModel.TotalPage;
            pendingDeliveryStatusViewModel.PageIndex  = pendingDeliveryOrderDataModel.PageIndex;
            #endregion
            #region getPendingReceivedOrderDataModel
            var pendingReceivedOrderDataModel = (from o in _readFromDb.Orders
                                                 where o.CustomerId == customer.Id && o.OrderStatus == Constants.DELIVERY
                                                 select new OrderDataModel()
            {
                Id = o.Id,
                CustomerId = customer.Id,
                AddressId = o.AddressId,
                CustomerName = customer.CustomerName,
                TotalAmount = o.TotalAmount,
                OrderDate = o.OrderDate,
                OrderStatus = o.OrderStatus,
                DeliveryDate = o.DeliveryDate,
            }).OrderByDescending(x => x.OrderDate).ToPagedList(indexNum, pageSize);
            var pendingReceivedList = pendingReceivedOrderDataModel.ToList();

            List <Order> PendingReceivedList = new List <Order>();
            foreach (OrderDataModel order in pendingReceivedList)
            {
                PendingReceivedList.Add(_readFromDb.Orders.Where(x => x.Id == order.Id).First());
            }
            pendingReceivedStatusViewModel.pageBar    = pendingReceivedOrderDataModel.getPageBar();
            pendingReceivedStatusViewModel.TotalCount = pendingReceivedOrderDataModel.TotalCount;
            pendingReceivedStatusViewModel.TotalPage  = pendingReceivedOrderDataModel.TotalPage;
            pendingReceivedStatusViewModel.PageIndex  = pendingReceivedOrderDataModel.PageIndex;
            #endregion
            #region getFinishedOrderDataModel
            var finishedOrderDataModel = (from o in _readFromDb.Orders
                                          where o.CustomerId == customer.Id && o.OrderStatus == Constants.FINISHED
                                          select new OrderDataModel()
            {
                Id = o.Id,
                CustomerId = customer.Id,
                AddressId = o.AddressId,
                CustomerName = customer.CustomerName,
                TotalAmount = o.TotalAmount,
                OrderDate = o.OrderDate,
                OrderStatus = o.OrderStatus,
                DeliveryDate = o.DeliveryDate,
            }).OrderByDescending(x => x.OrderDate).ToPagedList(indexNum, pageSize);
            var finishedList = finishedOrderDataModel.ToList();

            List <Order> FinishedList = new List <Order>();
            foreach (OrderDataModel order in finishedList)
            {
                FinishedList.Add(_readFromDb.Orders.Where(x => x.Id == order.Id).First());
            }
            pendingCommentStatusViewModel.pageBar    = finishedOrderDataModel.getPageBar();
            pendingCommentStatusViewModel.TotalCount = finishedOrderDataModel.TotalCount;
            pendingCommentStatusViewModel.TotalPage  = finishedOrderDataModel.TotalPage;
            pendingCommentStatusViewModel.PageIndex  = finishedOrderDataModel.PageIndex;
            #endregion
            #region getAllOrderByCustomerId
            var allOrderDataModel = (from o in _readFromDb.Orders
                                     where o.CustomerId == customer.Id
                                     select new OrderDataModel()
            {
                Id = o.Id,
                CustomerId = customer.Id,
                AddressId = o.AddressId,
                TotalAmount = o.TotalAmount,
                OrderDate = o.OrderDate,
                OrderStatus = o.OrderStatus,
                DeliveryDate = o.DeliveryDate,
            }).OrderByDescending(x => x.OrderDate).ToPagedList(indexNum, pageSize);
            var allList = allOrderDataModel.ToList();

            List <Order> AllList = new List <Order>();
            foreach (OrderDataModel order in allList)
            {
                AllList.Add(_readFromDb.Orders.Where(x => x.Id == order.Id).First());
            }
            allStatusViewModel.pageBar    = allOrderDataModel.getPageBar();
            allStatusViewModel.TotalCount = allOrderDataModel.TotalCount;
            allStatusViewModel.TotalPage  = allOrderDataModel.TotalPage;
            allStatusViewModel.PageIndex  = allOrderDataModel.PageIndex;
            #endregion
            allStatusViewModel.AllOrder = AllList;
            pendingPaymentStatusViewModel.PendingPaymentOrder   = PendingPaymentList;
            pendingDeliveryStatusViewModel.PendingDeliveryOrder = PendingDeliveryList;
            pendingReceivedStatusViewModel.PendingReceivedOrder = PendingReceivedList;
            pendingCommentStatusViewModel.PendingComment        = FinishedList;

            OrderViewModel orderViewModel = new OrderViewModel();
            orderViewModel.CurrentTab                     = (int)currentTab;
            orderViewModel.AllStatusViewModel             = allStatusViewModel;
            orderViewModel.PendingPaymentStatusViewModel  = pendingPaymentStatusViewModel;
            orderViewModel.PendingDeliveryStatusViewModel = pendingDeliveryStatusViewModel;
            orderViewModel.PendingReceivedStatusViewModel = pendingReceivedStatusViewModel;
            orderViewModel.PendingCommentStatusViewModel  = pendingCommentStatusViewModel;

            return(View("OrderList", orderViewModel));
        }