public ActionResult Create(Course course)
        {
            if (ModelState.IsValid)
            {
                var result = (from c in db.Colleges
                             join d in db.Departments
                             on c.CollegeName equals d.CollegeName
                             from cs in db.Colleges
                             join p in db.Programs
                             on cs.CollegeName equals p.CollegeName
                             from ps in db.Programs
                             join cr in db.Courses
                             on ps.ProgramName equals cr.ProgramName
                             where cr.CourseNumber == course.CourseNumber &
                                   cr.DepartmentName == course.DepartmentName &
                                   cr.ProgramName == course.ProgramName
                              select new { CourseName = course.CourseName }).ToList().Count();

                if (result == 0)
                {
                    course.DepartmentName = course.DepartmentName.Replace("string:", "").Trim();
                    course.ProgramName = course.ProgramName.Replace("string:", "").Trim();
                    db.Courses.Add(course);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
                else
                {
                    ModelState.AddModelError("CourseNumber", "Course Number already exists in DB.");
                    return View(course);
                }
            }

            return View(course);
        }
 public ActionResult Edit(Course course)
 {
     if (ModelState.IsValid)
     {
         course.DepartmentName = course.DepartmentName.Replace("string:", "").Trim();
         course.ProgramName = course.ProgramName.Replace("string:", "").Trim();
         db.Entry(course).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(course);
 }