public JsonResult GetStudent(int studentId) { bool state = true; string msg = string.Empty; CheckIn.Model.Student entity = null; int total = 0; try { var studentService = new SchoolCheckIn.CheckIn.Service.StudentServices(); entity = studentService.GetStudent(studentId); } catch (Exception e) { state = false; msg = e.Message; } return(new JsonResult { Data = new { State = state, Message = msg, Data = entity, Total = total }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public JsonResult GetStudentList(string name, string className, DateTime startTime, DateTime endTime, int pageIndex, int pageSize) { bool state = true; string msg = string.Empty; List <CheckIn.Model.Student> list = null; int total = 0; try { var studentService = new SchoolCheckIn.CheckIn.Service.StudentServices(); list = studentService.GetStudentList(name, className, startTime, endTime); total = list.Count; list = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); } catch (Exception e) { state = false; msg = e.Message; } return(new JsonResult { Data = new { State = state, Message = msg, Data = list, Total = total }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }