Ejemplo n.º 1
0
 public List <Menu> GetAll()
 {
     using (var context = new HRSSContext <Menu>())
     {
         return(context.Set <Menu>().ToList());
     }
 }
Ejemplo n.º 2
0
        public List <Group> GetDataFromGridSetting(Group gridSetting)
        {
            using (var context = new HRSSContext <Group>())
            {
                var result = context.Set <Group>().ToList();

                //// Filter field DataBind JqGrid
                if (!string.IsNullOrEmpty(gridSetting.GroupId))
                {
                    result = (gridSetting.GroupId != string.Empty) ? result.Where(x => x.GroupId.ToLower().Contains(gridSetting.GroupId.ToLower())).ToList() : result.ToList();
                }
                if (!string.IsNullOrEmpty(gridSetting.GroupName))
                {
                    result = (gridSetting.GroupName != string.Empty) ? result.Where(x => x.GroupName.ToLower().Contains(gridSetting.GroupName.ToLower())).ToList() : result.ToList();
                }

                // SortOrder field DataBind JqGrid
                switch (gridSetting.sortColumn)
                {
                case "GroupId":
                    result = (gridSetting.sortOrder == "desc") ? result.OrderByDescending(x => x.GroupId).ToList() : result.OrderBy(x => x.GroupId).ToList();
                    break;

                case "GroupName":
                    result = (gridSetting.sortOrder == "desc") ? result.OrderByDescending(x => x.GroupName).ToList() : result.OrderBy(x => x.GroupName).ToList();
                    break;

                default:
                    break;
                }

                // Paging total Record
                gridSetting.totalRecords = result.Count();

                //return result;
                return(result.Skip((gridSetting.pageIndex - 1) * gridSetting.pageSize).Take(gridSetting.pageSize).ToList());
            }
        }