public ActionResult Create([Bind(Include = "Id,Title,Credits,DepartmentID")]CourseViewModel course)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var department = _departmentRepository.FindById(course.DepartmentId);
                    var model = new Course();
                    model.Credits = course.Credits;
                    model.Department = department;
                    model.Title = course.Title;

                    _courseRepository.Create(model);
                    return RedirectToAction("Index");
                }
            }
            catch (Exception /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.)
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
            }
            PopulateDepartmentsDropDownList(course.DepartmentId);
            return View(course);
        }
 public void Update(Course course)
 {
     var existingCourse = Database.Courses.Find(x => x.Id == course.Id);
     Database.Courses.Remove(existingCourse);
     Database.Courses.Add(course);
 }
 public void Create(Course course)
 {
     course.Id = Database.Courses.Max(x => x.Id) + 1;
     Database.Courses.Add(course);
 }