public ActionResult UpdateList(string UserName) { try { var studentList = searchOperation.GetStudentList(); if (UserName == null) { return(View(studentList)); } else { var res = studentList.Where(x => x.user.UserName.Replace(" ", "") == UserName.Replace(" ", "")).ToList(); return(View(res)); } } catch (Exception ex) { return(View(ex)); } }
public ActionResult Studentslist(string sortOrder, string currentFilter, string searchString, int?page) { try { ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewBag.DateSortParm = sortOrder == "Date" ? "data_desc" : "Date"; ViewBag.DepartSortParm = sortOrder == "dep" ? "dep_desc" : "dep"; ViewBag.SessionSortParm = sortOrder == "ses" ? "ses_desc" : "ses"; ViewBag.RoomNoSortParm = sortOrder == "room" ? "room_desc" : "room"; if (searchString != null) { page = 1; } else { searchString = currentFilter; } var studentLists = searchOperation.GetStudentList(); if (!String.IsNullOrEmpty(searchString)) { studentLists = studentLists.Where(x => x.student.StudentName.Contains(searchString) || x.room.RoomNumber.ToString().Contains(searchString)).ToList(); } switch (sortOrder) { case "name_dasc": studentLists = studentLists.OrderByDescending(x => x.student.StudentName).ToList(); break; case "Date": studentLists = studentLists.OrderBy(x => x.HallEntryDate).ToList(); break; case "data_desc": studentLists = studentLists.OrderByDescending(x => x.HallEntryDate).ToList(); break; case "dep": studentLists = studentLists.OrderBy(x => x.department.DeptName).ToList(); break; case "dep_desc": studentLists = studentLists.OrderByDescending(x => x.department.DeptName).ToList(); break; case "ses_desc": studentLists = studentLists.OrderByDescending(x => x.departmentInfo.Session).ToList(); break; case "ses": studentLists = studentLists.OrderBy(x => x.departmentInfo.Session).ToList(); break; case "room_desc": studentLists = studentLists.OrderByDescending(x => x.room.RoomNumber).ToList(); break; case "room": studentLists = studentLists.OrderBy(x => x.room.RoomNumber).ToList(); break; default: studentLists = studentLists.OrderBy(x => x.student.StudentName).ToList(); break; } int pageSize = 8; int pageNumber = (page ?? 1); return(View(studentLists.ToPagedList(pageNumber, pageSize))); } catch (Exception ex) { return(View(ex)); } }