public IHttpActionResult PutStudent(int id, Student student)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != student.ID)
            {
                return BadRequest();
            }

            db.Entry(student).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public IHttpActionResult PostStudent(Student student)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Students.Add(student);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = student.ID }, student);
        }
 public void UpdateStudent(Student student)
 {
     _context.Entry(student).State = EntityState.Modified;
 }
 public ActionResult Edit(Student student)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _studentRepository.UpdateStudent(student);
             _studentRepository.Save();
             return RedirectToAction("Index");
         }
     }
     catch (DataException)
     {
         //Log the error (add a variable name after DataException)
         ModelState.AddModelError(string.Empty, ErrorMessage);
     }
     return View(student);
 }
 public void InsertStudent(Student student)
 {
     _context.Students.Add(student);
 }