public ActionResult Create() { CreateEditStudentViewModel vm = new CreateEditStudentViewModel { Student = new Student(), CompetencyHeaders = competencyHeaderRepository.AllIncluding(a => a.Competencies).ToList(), Edu = educationRepository.All.ToList() }; return View(vm); }
public ActionResult Create(CreateEditStudentViewModel data, HttpPostedFileBase image, IEnumerable<int> compIds, int eduId) { if (ModelState.IsValid) { saveStudentWithImageAndCompetency(data.Student, image, compIds, eduId); studentRepository.InsertOrUpdate(data.Student); //TODO this might be redundant2 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 ActionResult Edit(CreateEditStudentViewModel vm, HttpPostedFileBase image, IEnumerable<int> compIds, int eduId) { if(ModelState.IsValid) { saveStudentWithImageAndCompetency(vm.Student, image, compIds, eduId); studentRepository.InsertOrUpdate(vm.Student); //TODO this might be redundant return RedirectToAction("Index"); } return View(); }
public ActionResult Edit(int studentId) { // look up student in db Student student = studentRepository.Find(studentId); CreateEditStudentViewModel vm = new CreateEditStudentViewModel { Student = student, CompetencyHeaders = competencyHeaderRepository.AllIncluding(a => a.Competencies).ToList(), Edu = educationRepository.All.ToList() }; return View(vm); }