public async Task <IActionResult> DeleteConfirmed(TeacherDetailsVM teacherVM) { var teacherToDelete = _mapper.Map <Teacher>(teacherVM); var teacher = await _teacherService.DeleteAsync(teacherToDelete); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit([Bind("Id,FirstName,LastName,Salary")] TeacherDetailsVM teacherVM) { if (ModelState.IsValid) //is het valid? { var teacherToUpdate = _mapper.Map <Teacher>(teacherVM); var updatedTeacher = await _teacherService.UpdateAsync(teacherToUpdate); //var teacherVMToReturn = _mapper.Map<TeacherDetailsVM>(updatedTeacher); return(RedirectToAction(nameof(Index))); } return(View(teacherVM)); }
public async Task <IActionResult> Edit([Bind("Id,FirstName,LastName,Salary")] TeacherDetailsVM teacherVM) { if (ModelState.IsValid) //is het valid? { var teacherToUpdate = _mapper.Map <Teacher>(teacherVM); // maak van de vm een teacher object var updatedTeacher = await _teacherService.UpdateAsync(teacherToUpdate); // geef het teacher object mee aan de update functie var teacherVMToReturn = _mapper.Map <TeacherDetailsVM>(updatedTeacher); // map de geupdate teacher terug naar een VM return(View(teacherVMToReturn)); // return de view met de VM } return(View(teacherVM)); // De view was niet valid, maak opnieuw de view met de invalid teacherVM }
public IActionResult Detail(int?id) { TeacherDetailsVM teacherDetailsVM = new TeacherDetailsVM { Teacher = _db.Teachers.Where(t => t.IsDeleted == false).Include(t => t.TeacherDetail).Include(t => t.TeacherSkill). ThenInclude(t => t.SkillsTeacherDetail).FirstOrDefault(t => t.Id == id), KamranTeacherDetail = _db.KamranTeacherDetails.Where(k => k.IsDeleted == false).FirstOrDefault(), ContactTeacherDetail = _db.ContactTeacherDetails.Where(con => con.IsDeleted == false).FirstOrDefault(), SkillsTeacherDetails = _db.SkillsTeacherDetails.Where(s => s.IsDeleted == false).ToList() }; return(View(teacherDetailsVM)); }
public async Task <IActionResult> Index(string searchString) { var teachers = await _teacherService.GetListAsync(); if (!string.IsNullOrEmpty(searchString)) { teachers = teachers.Where(s => s.FirstName.Contains(searchString) || s.LastName.Contains(searchString)); } var teacherVM = new TeacherDetailsVM { Teachers = teachers.ToList() }; return(View(teacherVM)); }
public IActionResult Details(int?id) { TempData["controllerName"] = this.ControllerContext.RouteData.Values["controller"].ToString(); if (id == null) { return(NotFound()); } TeacherDetailsVM teacherDetailsVM = new TeacherDetailsVM { TeacherBasicInfo = _context.TeacherBasicInfos.Where(tbi => tbi.IsDeleted == false).Include(tbi => tbi.OurTeacher) .FirstOrDefault(tbi => tbi.OurTeacherId == id), TeacherContactInfo = _context.TeacherContactInfos.Where(tci => tci.IsDeleted == false).Include(tbi => tbi.OurTeacher) .FirstOrDefault(tbi => tbi.OurTeacherId == id), TeacherSkills = _context.TeacherSkills.Where(ts => ts.IsDeleted == false).ToList(), TeacherSkillSkills = _context.TeacherSkillSkills.ToList() }; return(View(teacherDetailsVM)); }