public ActionResult Add() { var viewModel = new OrdersAddViewModel(); viewModel.Init(Context); return(View(viewModel)); }
public ActionResult Add(OrdersAddViewModel viewModel) { // ValidateEmployee(viewModel.Employee); if (ModelState.IsValid) { var order = viewModel.Order; Context.Orders.Add(order); Context.SaveChanges(); TempData["Message"] = "Order was successfully added!"; return(RedirectToAction("Detail", new { id = order.Id })); } viewModel.Init(Context); return(View(viewModel)); }