public ActionResult Edit(Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(student);
 }
        public ActionResult Create(Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(student);
        }
        public ActionResult Create(Student employeeToCreate)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _repository.CreateNewStudent(employeeToCreate);
                    return RedirectToAction("Index");
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex);
                ViewData["CreateError"] = "Unable to create; view innerexception";
            }
            return View("Create");

        }
        public ActionResult Edit(Student student)
        {
            Student cnt = _repository.GetStudentById(student.StudentID);
            try
            {
                if (TryUpdateModel(cnt))
                {
                    _repository.SaveChanges();
                    return RedirectToAction("Index");
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                    ViewData["EditError"] = ex.InnerException.ToString();
                else
                    ViewData["EditError"] = ex.ToString();
            }
#if DEBUG
            foreach (var modelState in ModelState.Values)
            {
                foreach (var error in modelState.Errors)
                {
                    if (error.Exception != null)
                    {
                        throw modelState.Errors[0].Exception;
                    }
                }
            }
#endif
            return View(cnt);
        }
 public void CreateNewStudent(Student employeeToCreate)
 {
     dbContext.Students.Add(employeeToCreate);
     dbContext.SaveChanges();
 }