public ActionResult Create(Teacher teacher)
 {
     ViewBag.DesignationId = new SelectList(db.Designations, "DesignationId", "Name", teacher.DesignationId);
     ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Code", teacher.DepartmentId);
     if (ModelState.IsValid)
     {
         teacher.RemainingCredit = teacher.CreditToBeTaken;
         db.Teachers.Add(teacher);
         db.SaveChanges();
         ViewBag.Message = teacher.Name + " has been saved in database.";
         return View();
     }
     return View();
 }
 public ActionResult Edit(Teacher teacher)
 {
     if (ModelState.IsValid)
     {
         db.Entry(teacher).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.DesignationId = new SelectList(db.Designations, "DesignationId", "Name", teacher.DesignationId);
     ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Code", teacher.DepartmentId);
     return View(teacher);
 }