// POST: Admin/Order/UpdateStatus
        public ActionResult UpdateStatus(int id, short Statuses)
        {
            try
            {
                if (Statuses == 99)
                {
                    var paymentWorker = new PaymentWorker();
                    var payments = paymentWorker.GetManagerPaymentEntitiesByOrder(id);
                    if (payments.Status != 99)
                    {
                        return RedirectToAction("Detail", new { id = id });
                    }
                }

                var orderWorker = new OrderWorker();
                orderWorker.UpdateOrderStatus(id, Statuses);
                return RedirectToAction("Detail", new { id = id });
            }
            catch (Exception ex)
            {
                this.ShowError(ex);
                return null;
            }
            
        }
        // GET: Admin/Order/Detail
        public ActionResult Detail(int id)
        {
            try
            {
                ViewBag.Id = id;

                var orderWorker = new OrderWorker();
                var paymentWorker = new PaymentWorker();
                var customerWorker = new CustomerWorker();

                var model = orderWorker.GetManagerOrderEdit(id);
                var paymodel = paymentWorker.GetManagerPaymentEntitiesByOrder(id);
            
                ViewBag.User = customerWorker.GetCustomerUser(model.Customer.UserId);

                ViewBag.Statuses = SmartBazaar.Web.Models.Common.OrderHeadsListProvider.GetStatuses().Select(s => new SelectListItem { Text = s.Value, Value = s.Key.ToString(), Selected = s.Key == model.Status }).AsEnumerable();
                if (paymodel != null)
                {
                    ViewBag.Payment = paymodel;
                    ViewBag.PayId = paymodel.Id;
                    ViewBag.PayStatuses = SmartBazaar.Web.Models.Common.PaymentEntitiesListsProvider.GetStatuses().Select(s => new SelectListItem { Text = s.Value, Value = s.Key.ToString(), Selected = s.Key == paymodel.Status });
                }
                else
                {
                    ViewBag.PayStatuses = SmartBazaar.Web.Models.Common.PaymentEntitiesListsProvider.GetStatuses().Select(s => new SelectListItem { Text = s.Value, Value = s.Key.ToString()});
                }

                return View(model);
            }
            catch (Exception ex)
            {
                this.ShowError(ex);
                return null;
            }
        }