public ActionResult GetData(EmploymentStudentVisitLogCriteria c) { var m = new LigerGridModel(); this.BeforeGetData(c); var r = this.Service.FindByCriteria(c); this.AfterGetData(m, c, r); m.Total = r.RecordCount; r.Data.ForEach(o => { this.AddRowToGridModel(m, o); }); this.AfterBuildGridModel(m, c, r); return this.Json(m, JsonRequestBehavior.AllowGet); }
partial void AfterGetData(LigerGridModel gm, EmploymentStudentVisitLogCriteria c, PagedModel<EmploymentStudentVisitLog> pm);
partial void BeforeGetData(EmploymentStudentVisitLogCriteria c);
public PagedModel<EmploymentStudentVisitLog> FindByCriteria(EmploymentStudentVisitLogCriteria c) { PagedModel<EmploymentStudentVisitLog> m = new PagedModel<EmploymentStudentVisitLog>(); var r = this.Repository.FindByCriteria(c); if(!String.IsNullOrEmpty(c.sortname)){ if(c.sortname.ToLower().Equals("id")){ if(c.sortorder.ToLower().Equals("asc")){ r = r.OrderBy(o=>o.Id); }else{ r = r.OrderByDescending(o=>o.Id); } } if(c.sortname.ToLower().Equals("studentid")){ if(c.sortorder.ToLower().Equals("asc")){ r = r.OrderBy(o=>o.StudentId); }else{ r = r.OrderByDescending(o=>o.StudentId); } } if(c.sortname.ToLower().Equals("visitorid")){ if(c.sortorder.ToLower().Equals("asc")){ r = r.OrderBy(o=>o.VisitorId); }else{ r = r.OrderByDescending(o=>o.VisitorId); } } if(c.sortname.ToLower().Equals("time")){ if(c.sortorder.ToLower().Equals("asc")){ r = r.OrderBy(o=>o.Time); }else{ r = r.OrderByDescending(o=>o.Time); } } if(c.sortname.ToLower().Equals("position")){ if(c.sortorder.ToLower().Equals("asc")){ r = r.OrderBy(o=>o.Position); }else{ r = r.OrderByDescending(o=>o.Position); } } if(c.sortname.ToLower().Equals("objective")){ if(c.sortorder.ToLower().Equals("asc")){ r = r.OrderBy(o=>o.Objective); }else{ r = r.OrderByDescending(o=>o.Objective); } } if(c.sortname.ToLower().Equals("content")){ if(c.sortorder.ToLower().Equals("asc")){ r = r.OrderBy(o=>o.Content); }else{ r = r.OrderByDescending(o=>o.Content); } } } m.RecordCount = r.Count(); if (c.pagesize.HasValue) { int page = c.page ?? 1; int pageCount = m.RecordCount / c.pagesize.Value; if (m.RecordCount % c.pagesize.Value > 0) { pageCount++; } int skip = (page - 1) * c.pagesize.Value; if (skip > 0) { r = r.Skip(skip); } r = r.Take(c.pagesize.Value); } m.Data = r.ToList(); return m; }