예제 #1
0
        public ActionResult Add()
        {
            var viewModel = new OrdersAddViewModel();

            viewModel.Init(Context);

            return(View(viewModel));
        }
예제 #2
0
        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));
        }