public IActionResult CreatePickOrder(PickOrderViewModel model) { if (ModelState.IsValid) { PickOrder pickOrder = model.CopyTo(); if (pickOrder.Orders.Any()) { if (pickOrder.Orders.Count >= 4) { if (this._pickOrder.CreatePickOrder(pickOrder)) { TempData["message"] = "Pickorder has been created"; return(RedirectToAction("PickOrders")); } else { TempData["errormessage"] = "Pickorder cannot be created"; return(View("PickOrder", model)); } } else { TempData["errormessage"] = "Must be atleast 4 orders within a pickorder"; return(RedirectToAction("PickOrder", model)); } } else { TempData["errormessage"] = "Pickorder cannot be empty"; return(RedirectToAction("PickOrder", model)); } } return(View("PickOrder", model)); }
public IActionResult UpdatePickOrder(PickOrderViewModel model) { //TODO can not really remove only add new orders.... if (ModelState.IsValid) { PickOrder pickOrder = model.CopyTo(); if (pickOrder.Orders.Count >= 4) { if (this._pickOrder.UpdatePickOrder(pickOrder)) { try { TempData["message"] = "PickOrder has been succesfully updated."; return(RedirectToAction("PickOrders")); } catch (Exception e) { TempData["message"] = e.Message; return(RedirectToAction("PickOrders")); } } else { TempData["errormessage"] = "PickOrder cannot be updated."; return(RedirectToAction("PickOrders")); } } else { TempData["errormessage"] = "Must be atleast 4 orders within a pickorder"; return(View("PickOrder", model)); } } return(View("PickOrder", model)); }