public OrdersEditViewModel GetOrderEditPageVM(int id) { var orderVM = GetOrder(id); if (orderVM == null) { return(null); } var materials = u_repo.GetMaterials().ToList(); var orderEditVM = new OrdersEditViewModel { Materials = materials, Order = orderVM, OrderId = id }; return(orderEditVM); }
public ActionResult Edit(OrdersEditViewModel viewModel) { // ValidateEmployee(viewModel.Employee); if (ModelState.IsValid) { var order = viewModel.Order; _orderRepo.Update(order); TempData["Message"] = "Order was successfully updated!"; return(RedirectToAction("Detail", new { id = order.Id })); } viewModel.Init(Context); return(View(viewModel)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var order = _orderRepo.Get((int)id); if (order == null) { return(HttpNotFound()); } var viewModel = new OrdersEditViewModel() { Order = order }; viewModel.Init(Context); return(View(viewModel)); }