public ActionResult AddClassHour(int id)
 {
     TempData["weekDays"] = new SelectList(weekDays, "M");
     ClassHour newClassHour = new ClassHour();
     newClassHour.classId = id;
     return View(newClassHour);
 }
        public ActionResult AddClassHour(ClassHour classhour, FormCollection formValues)
        {
            classhour.day = formValues["selectedDay"];
            classhour.ModifiedBy = User.Identity.Name;
            classhour.ModifiedOn = DateTime.Now;
            var result = repository.SaveClassHour(classhour);
            if (result > 0)
                TempData["message"] = string.Format("Session with ID {0} has been saved.", classhour.id);
            else
                TempData["message"] = string.Format("Unsuccessful procedure!");

            return RedirectToAction("ClassHourList/" + Session["ClassID"]);
        }
 public void SaveClassHour(ClassHour classHour)
 {
     context.ClassHours.Add(classHour);
     context.SaveChanges();
 }
 public void DeleteClasshour(ClassHour classHour)
 {
     context.ClassHours.Remove(classHour);
     context.SaveChanges();
 }
 //add class hour
 public int SaveClassHour(ClassHour classHour)
 {
     if (classHour.id == 0)
     {
         context.ClassHours.Add(classHour);
     }
     else
     {
         context.Entry(classHour).State = System.Data.EntityState.Modified;
     }
     var result = context.SaveChanges();
     return result;
 }
 //delete class hour
 public int DeleteClasshour(ClassHour classHour)
 {
     context.ClassHours.Remove(classHour);
     var result = context.SaveChanges();
     return result;
 }