Exemplo n.º 1
0
        public ActionResult List()
        {
            var model = new DepartmentsViewModel
            {
                Departments = Context.Departments.OrderBy(x => x.Name).ToList()
            };

            return View(model);
        }
Exemplo n.º 2
0
        public ActionResult Create(DepartmentsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Departments = Context.Departments.OrderBy(x => x.Name).ToList();
                return View("List", model);
            }

            var departmentService = new DepartmentService(Context);
            departmentService.Create(model.NewDepartmentName);

            return RedirectToAction("List");
        }