Ejemplo n.º 1
0
 public ActionResult EditOrder(EditOrderViewModel model) {
     if (!ModelState.IsValid) {
         TempData["EditOrder"] = "Model validation Error";
         return RedirectToAction("ViewAllOrders", "Management");
     }
     OrderManagerResult orderManagerResult;
     if (model.StatusStr == "Opened") {
         orderManagerResult =
         OrderManager.EditOrder(
                                new Order {
                                    OrderID = int.Parse(model.OrderID),
                                    StartDate = model.StartDate,
                                    EndDate = model.EndDate,
                                    Status = false
                                },
                                model.Email);
         if (!orderManagerResult.Success) {
             TempData["EditOrder"] = orderManagerResult.ErrorMessage;
             return RedirectToAction("ViewAllOrders", "Management");
         }
         TempData["EditOrder"] = "Order edited successfully";
         return RedirectToAction("ViewAllOrders", "Management");
     }
     orderManagerResult =
     OrderManager.EditOrder(
                            new Order {OrderID = int.Parse(model.OrderID), StartDate = model.StartDate, EndDate = model.EndDate, Status = true},
                            model.Email);
     if (!orderManagerResult.Success) {
         TempData["EditOrder"] = orderManagerResult.ErrorMessage;
         return RedirectToAction("ViewAllOrders", "Management");
     }
     TempData["EditOrder"] = "Order edited successfully";
     return RedirectToAction("ViewAllOrders", "Management");
 }
Ejemplo n.º 2
0
 public ActionResult EditOrder(string orderID) {
     //Order orderToEdit = new Order {OrderID = int.Parse(orderID)};
     OrderManagerResult orderManagerResult = OrderManager.GetOrder(orderID);
     if (!orderManagerResult.Success) {
         TempData["EditOrder"] = orderManagerResult.ErrorMessage;
         return RedirectToAction("Index", "Management");
     }
     UserManagerResult userManagerResult = UserManager.GetUserByUserID(orderManagerResult.Order.AccountID);
     if (!userManagerResult.Success) {
         TempData["EditOrder"] = orderManagerResult.ErrorMessage;
         return RedirectToAction("Index", "Management");
     }
     EditOrderViewModel model = new EditOrderViewModel {
         StartDate = orderManagerResult.Order.StartDate.Replace(" ", String.Empty),
         EndDate = orderManagerResult.Order.EndDate.Replace(" ", String.Empty),
         Email = userManagerResult.User.Email,
         OrderID = orderManagerResult.Order.OrderID.ToString()
     };
     model.StatusStr = orderManagerResult.Order.Status ? "Closed" : "Opened";
     return View(model);
 }