public DataTablesResult <StudentViewModel> GetCollectionStudents(DataTablesParam dataTableParam) { var searchString = dataTableParam.GetSearchString(); ViewBag.EditActionLink = "/Administration/EditStudent"; ViewBag.DeleteActionLink = "/Administration/DeleteStudent"; ViewBag.StatActionLink = "/Administration/Attendance"; var students = StudentManagementService.GetStudentsPageable(pageInfo: dataTableParam.ToPageInfo(), searchString: searchString); return(DataTableExtensions.GetResults(students.Items.Select(s => StudentViewModel.FromStudent(s, PartialViewToString("_EditGlyphLinks", s.Id))), dataTableParam, students.TotalCount)); }
// GET /student/details/{id} public IActionResult Details(int id) { var student = svc.GetStudent(id); if (student == null) { Alert("Student Not Found", AlertType.warning); return(RedirectToAction(nameof(Index))); } return(View(StudentViewModel.FromStudent(student))); }
// GET /student/edit/{id} public IActionResult Edit(int id) { // load student via service var s = svc.GetStudent(id); if (s == null) { Alert("Student Not Found", AlertType.warning); return(RedirectToAction(nameof(Index))); } // pass student to view for editing return(View(StudentViewModel.FromStudent(s))); }