Beispiel #1
0
        public PagedModel<UserGroup> FindByCriteria(UserGroupCriteria c)
        {
            PagedModel<UserGroup> m = new PagedModel<UserGroup>();
            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("name")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.Name);
                }else{
                    r = r.OrderByDescending(o=>o.Name);
                }
            }

            }

            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;
        }
Beispiel #2
0
 public ActionResult GetData(UserGroupCriteria 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);
 }
Beispiel #3
0
partial         void BeforeGetData(UserGroupCriteria c);
Beispiel #4
0
partial         void AfterGetData(LigerGridModel gm, UserGroupCriteria c, PagedModel<UserGroup> pm);
Beispiel #5
0
partial         void AfterBuildGridModel(LigerGridModel gm, UserGroupCriteria c, PagedModel<UserGroup> pm);