public void EditCourse(Course course)
 {
     context.Entry(course).State = System.Data.EntityState.Modified;
     context.SaveChanges();
 }
 public void AddCourse(string userName, string title, string coursenumber, string description, string skillset, int credits)
 {
     var newCourse = new Course { Title = title, SkillSet = skillset, Credits = credits, CreatedBy = userName, CreatedOn = DateTime.Now, Active = true, SelfStudy = false, Description = description, CourseNumber = coursenumber };
     // var tempRoster = context.Roster;
     context.Courses.Add(newCourse);
     context.SaveChanges();
 }
 public void DeleteCourse(Course course)
 {
     foreach (var classes in course.Classes.ToList())
     {
         DeleteClass(classes);
     }
     context.Courses.Remove(course);
 }
        public ActionResult Edit(Course course)
        {
            if (ModelState.IsValid)
            {

                var cookie = Request.Cookies[FormsAuthentication.FormsCookieName];
                FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);
                var username = ticket.Name;
                //                var user = repository.Users.SingleOrDefault(u => u.userName == username);

                course.ModifiedBy = username;
                course.ModifiedOn = DateTime.Now;

                repository.EditCourse(course);
            }
            TempData["message"] = string.Format("Course with ID {0} has been saved.", course.CourseID);
            return RedirectToAction("Edit", "AddRemoveCourse");
        }