Ejemplo n.º 1
0
        public ActionResult Add()
        {
            var viewModel = new OrdersAddViewModel();

            viewModel.Init(Context);

            return(View(viewModel));
        }
Ejemplo n.º 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));
        }