Пример #1
0
        // GET: Dashboard/Delivery
        public ActionResult Index()
        {
            try
            {
                SearchOrdersListViewModel model = new SearchOrdersListViewModel();

                var apiResponse = AsyncHelpers.RunSync <JObject>(() => ApiCall.CallApi("api/Admin/GetReadyForDeliveryOrders", User, GetRequest: true));

                if (apiResponse == null || apiResponse is Error)
                {
                    return(new HttpStatusCodeResult(500, "Internal Server Error"));
                }
                else
                {
                    model = apiResponse.GetValue("Result").ToObject <SearchOrdersListViewModel>();

                    foreach (var order in model.Orders)
                    {
                        order.DeliveryMen.Insert(0, new DelivererOptionsViewModel {
                            Id = 0, Name = "None"
                        });
                        IEnumerable <SelectListItem> selectList = from deliverer in order.DeliveryMen
                                                                  select new SelectListItem
                        {
                            Selected = (deliverer.Id == order.DeliveryManId),
                            Text     = deliverer.Name,
                            Value    = deliverer.Id.ToString()
                        };
                        order.DeliveryMenOptions = new SelectList(selectList, order.DeliveryManId);
                        //order.DeliveryMenOptions.SelectedValue = order.DeliveryManId;
                    }
                }
                model.Orders = model.Orders.Distinct(new SearchOrdersViewModel.Comparer()).ToList();
                model.SetSharedData(User);
                return(View(model));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(Utility.LogError(ex), "Internal Server Error"));
            }
        }
Пример #2
0
        public ActionResult SaveOrderStatus(List <ChangeOrderStatusModel> selectedOrders)
        {
            try
            {
                if (selectedOrders == null)
                {
                    return(new HttpStatusCodeResult((int)HttpStatusCode.Forbidden, "Select an order to save"));
                }

                foreach (var order in selectedOrders)
                {
                    order.Status = order.Status - 1;
                }

                ChangeOrderStatusListModel postModel = new ChangeOrderStatusListModel();
                postModel.Orders = selectedOrders;

                var apiResponse = AsyncHelpers.RunSync <JObject>(() => ApiCall.CallApi("api/Admin/ChangeOrderStatus", User, postModel));

                if (apiResponse == null || apiResponse is Error)
                {
                    return(new HttpStatusCodeResult(500, "Internal Server Error"));
                }
                else
                {
                    SearchOrdersListViewModel model = new SearchOrdersListViewModel();
                    model.OrderStatusOptions = Utility.GetOrderStatusOptions();
                    foreach (var order in model.Orders)
                    {
                        order.OrderStatus = order.OrderStatus + 1;
                    }
                    model.SetSharedData(User);
                    return(PartialView("_SearchOrderResults", model));
                }
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult((int)HttpStatusCode.InternalServerError, "Internal Server Error"));
            }
        }
Пример #3
0
        public ActionResult SearchOrderResults(SearchOrderModel model)
        {
            var response = AsyncHelpers.RunSync <JObject>(() => ApiCall.CallApi
                                                              ("api/Admin/SearchOrders", User, null, true, false, null,
                                                              "OrderStatusId=" + (model.OrderStatusId == 0 ? null : model.OrderStatusId - 1),
                                                              "PaymentStatusId=" + (model.PaymentStatusId == 0 ? null : model.PaymentStatusId - 1),
                                                              "PaymentMethodId=" + (model.PaymentMethodId == 0 ? null : model.PaymentMethodId - 1),
                                                              "StoreId=" + (model.StoreId == 0 ? null : model.StoreId),
                                                              "StartDate=" + (model.StartDate == DateTime.MinValue ? DateTime.Now : model.StartDate),
                                                              "EndDate=" + (model.EndDate == DateTime.MinValue ? DateTime.Now : model.EndDate)));

            SearchOrdersListViewModel returnModel = new SearchOrdersListViewModel();

            if (response is Error)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, (response as Error).ErrorMessage));
            }
            else
            {
                returnModel = response.GetValue("Result").ToObject <SearchOrdersListViewModel>();
            }

            foreach (var item in returnModel.Orders)
            {
                item.CustomerName      = item.CustomerName == null ? "-" : item.CustomerName;
                item.OrderItemsComaSep = item.OrderItemsComaSep == null ? "-" : item.OrderItemsComaSep;
            }

            returnModel.OrderStatusOptions = Utility.GetOrderStatusOptions();

            foreach (var order in returnModel.Orders)
            {
                order.OrderStatus = order.OrderStatus + 1;
            }
            returnModel.SetSharedData(User);
            return(PartialView("_SearchOrderResults", returnModel));
        }