public ActionResult Edit(Student student, HttpPostedFileBase image)
 {
     if(ModelState.IsValid)
     {
         student.SaveImage(image, Server.MapPath("~"), "/ProfileImages/");
         studentRepo.InsertOrUpdate(student);
         return RedirectToAction("Index");
     }
     return View();
 }
 public void InsertOrUpdate(Student student)
 {
     if (student.StudentId == 0) //new
     {
         context.Students.Add(student);
     }
     else //edit
     {
         context.Entry(student).State = EntityState.Modified;
     }
     this.Save();
 }
 public ActionResult Create(Student student, HttpPostedFileBase image)
 {
     if (ModelState.IsValid)
     {
         student.SaveImage(image, Server.MapPath("~"), "/ProfileImages/");
         studentRepo.InsertOrUpdate(student);
         return RedirectToAction("Index");
         // alternative (not recommendable because if we change the list in View we have to change it here too):
         // return View("Index"), db.Students.ToList();
     }
     return View();
 }
 public void Delete(Student student)
 {
     context.Students.Remove(student);
     this.Save();
 }
        private void saveStudentWithImageAndCompetency(Student student, HttpPostedFileBase image, IEnumerable<int> compIds, int eduId)
        {
            string path = Server != null ? Server.MapPath("~") : "";
            student.SaveImage(image, path, "/ProfileImages/");

            //TODO check if i actually need these 2 lines:
            // get competencies
            student.Competencies = competencyRepository.All.Where(x => compIds.Contains(x.CompetencyId)).ToList();
            // get education
            student.Education = educationRepository.Find(eduId);

            studentRepository.InsertOrUpdate(student);
        }