public IActionResult ExportExcel(StudentListVM vm) { vm.SearcherMode = vm.Ids != null && vm.Ids.Count > 0 ? ListVMSearchModeEnum.CheckExport : ListVMSearchModeEnum.Export; var data = vm.GenerateExcel(); return(File(data, "application/vnd.ms-excel", $"Export_ActionLog_{DateTime.Now.ToString("yyyy-MM-dd")}.xls")); }
public ActionResult listStudents() { StudentListVM slvm = new StudentListVM(); slvm.SList = BusinessLayer.BusinessAdmin.listStudents(); return(View(slvm)); }
public ActionResult Index() { var vm = new StudentListVM(); var studentList = _BLL.Get(); vm.Students = studentList; return(View(vm)); }
public string Search(StudentListVM vm) { if (ModelState.IsValid) { return(vm.GetJson(false)); } else { return(vm.GetError()); } }
public IActionResult Students() { StudentListVM studentListVM = new StudentListVM(); Guid teacherId = Guid.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value); Teacher teacher = _teacherService.GetTeacherWithStudentsAndCourses(teacherId); studentListVM.Teacher = teacher; foreach (var stud in teacher.TeacherStudents) { User student = _userService.FindById(stud.StudentId); studentListVM.Students.Add(student); } return(View(studentListVM)); }
public StudentListVM GetStudents(ParamObject _params) { StudentListVM report = new StudentListVM(); try { var param = new { @SearchValue = _params.SearchValue, @FilterTypeID = _params.FilterTypeID, @PageNumber = _params.PageNumber, @PageSize = _params.PageSize }; using (IDbConnection db = new SqlConnection(connectionStr)) { using (var result = db.QueryMultiple("GetStudents", param: param, commandType: CommandType.StoredProcedure)) { report.status = 1; report.message = "Student list return Successfully."; report._studentList = result.Read <StudentObject>().ToList(); report._subjectList = result.Read <SubjectObject>().ToList(); } } } catch (SqlException ex) { report.status = -100; report.message = ex.Message; } catch (DataException ex) { report.status = -100; report.message = ex.Message; } catch (Exception ex) { report.status = -100; report.message = ex.Message.ToString(); } return(report); }
public ActionResult Index(string sortOn, string searchOn = "") { var studentRole = RoleManager.FindByName("Student"); List <StudentListVM> studentListForVM = new List <StudentListVM>(); var students = db.Users .Where(u => u.Roles.FirstOrDefault().RoleId == studentRole.Id) .ToList(); foreach (var student in students) { StudentListVM studentForVM = new StudentListVM(); studentForVM.Id = student.Id; studentForVM.FirstName = student.FirstName; studentForVM.LastName = student.LastName; studentForVM.CourseId = student.CourseId.GetValueOrDefault(); studentForVM.CourseName = db.Courses.Find(studentForVM.CourseId).Name; studentForVM.Email = student.Email; studentForVM.PhoneNumber = student.PhoneNumber; studentListForVM.Add(studentForVM); } if (sortOn != null && students != null) { switch (sortOn) { case "firstname_asc": studentListForVM = studentListForVM.OrderByDescending(s => s.FirstName).ToList(); ViewBag.SortOrderFirstName = "firstname_desc"; break; case "firstname_desc": studentListForVM = studentListForVM.OrderBy(s => s.FirstName).ToList(); ViewBag.SortOrderFirstName = "firstname_asc"; break; case "lastname_asc": studentListForVM = studentListForVM.OrderByDescending(s => s.LastName).ToList(); ViewBag.SortOrderLastName = "lastname_desc"; break; case "lastname_desc": studentListForVM = studentListForVM.OrderBy(s => s.LastName).ToList(); ViewBag.SortOrderLastName = "lastname_asc"; break; case "email_asc": studentListForVM = studentListForVM.OrderByDescending(s => s.Email).ToList(); ViewBag.SortOrderEmail = "email_desc"; break; case "email_desc": studentListForVM = studentListForVM.OrderBy(s => s.Email).ToList(); ViewBag.SortOrderEmail = "email_asc"; break; case "phonenumber_asc": studentListForVM = studentListForVM.OrderByDescending(s => s.PhoneNumber).ToList(); ViewBag.SortOrderPhoneNumber = "phonenumber_desc"; break; case "phonenumber_desc": studentListForVM = studentListForVM.OrderBy(s => s.PhoneNumber).ToList(); ViewBag.SortOrderPhoneNumber = "phonenumber_asc"; break; case "coursename_asc": studentListForVM = studentListForVM.OrderByDescending(s => s.CourseName).ToList(); ViewBag.SortOrderCourseName = "coursename_desc"; break; case "coursename_desc": studentListForVM = studentListForVM.OrderBy(s => s.CourseName).ToList(); ViewBag.SortOrderCourseName = "coursename_asc"; break; default: ViewBag.SortOrderFirstName = "firstname_desc"; ViewBag.SortOrderLastName = "lastname_desc"; ViewBag.SortOrderEmail = "email_desc"; ViewBag.SortOrderPhoneNumber = "phonenumber_desc"; ViewBag.SortOrderCourseName = "coursename_desc"; break; } } else { ViewBag.SortOrderFirstName = "firstname_desc"; ViewBag.SortOrderLastName = "lastname_desc"; ViewBag.SortOrderEmail = "email_desc"; ViewBag.SortOrderPhoneNumber = "phonenumber_desc"; ViewBag.SortOrderCourseName = "coursename_desc"; } if (!String.IsNullOrEmpty(searchOn)) { studentListForVM = studentListForVM.Where(s => s.FirstName.ToLower().Contains(searchOn.ToLower())) .Concat(studentListForVM.Where(s => s.LastName.ToLower().Contains(searchOn.ToLower()))) .Concat(studentListForVM.Where(s => s.Email.ToLower().Contains(searchOn.ToLower()))) .Concat(studentListForVM.Where(s => s.CourseName.ToLower().Contains(searchOn.ToLower()))) .Distinct() .ToList(); ViewBag.SearchOn = searchOn; } return(View(studentListForVM)); }
public string Search(StudentListVM vm) { return(vm.GetJson(false)); }
public IActionResult ExportExcel(StudentListVM vm) { return(vm.GetExportData()); }