Пример #1
0
        public ActionResult Create(CourseCreateOrEdit course)
        {
            if (ModelState.IsValid)
            {
                var item = db.Courses.Create();

                item.InjectFrom(course);

                db.Courses.Add(item);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "Name", course.DepartmentID);
            return(View(course));
        }
Пример #2
0
        public ActionResult Create(DepartmentEdit department)
        {
            if (ModelState.IsValid)
            {
                var item = db.Departments.Create();

                item.InjectFrom(department);

                db.Departments.Add(item);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            ViewBag.InstructorID = new SelectList(db.People, "ID", "FirstName");

            return(View(department));
        }