Esempio n. 1
0
        public PagedModel<UserInGroup> FindByCriteria(UserInGroupCriteria c)
        {
            PagedModel<UserInGroup> m = new PagedModel<UserInGroup>();
            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("usergroupid")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.UserGroupId);
                }else{
                    r = r.OrderByDescending(o=>o.UserGroupId);
                }
            }
            if(c.sortname.ToLower().Equals("userid")){
                if(c.sortorder.ToLower().Equals("asc")){
                    r = r.OrderBy(o=>o.UserId);
                }else{
                    r = r.OrderByDescending(o=>o.UserId);
                }
            }

            }

            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;
        }
Esempio n. 2
0
 public ActionResult GetData(UserInGroupCriteria 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);
 }
Esempio n. 3
0
partial         void AfterGetData(LigerGridModel gm, UserInGroupCriteria c, PagedModel<UserInGroup> pm);
Esempio n. 4
0
partial         void BeforeGetData(UserInGroupCriteria c);
Esempio n. 5
0
partial         void AfterBuildGridModel(LigerGridModel gm, UserInGroupCriteria c, PagedModel<UserInGroup> pm);