Beispiel #1
0
        public virtual IList <T> Find(F filter, FetchOptoins fetchOptoins = null)
        {
            var crit = session.CreateCriteria <T>();

            if (filter != null)
            {
                SetupFilter(crit, filter);
            }

            if (fetchOptoins != null)
            {
                SetupFetchOptions(crit, fetchOptoins);
            }

            return(crit.List <T>());
        }
Beispiel #2
0
        protected virtual void SetupFetchOptions(ICriteria crit, FetchOptoins fetchOptoins)
        {
            if (!string.IsNullOrEmpty(fetchOptoins.SortExpression))
            {
                crit.AddOrder(fetchOptoins.SortDirection == SortDirection.Asc ?
                              Order.Asc(fetchOptoins.SortExpression) :
                              Order.Desc(fetchOptoins.SortExpression));
            }

            if (fetchOptoins.First != null)
            {
                crit.SetFirstResult(fetchOptoins.First.Value);
            }

            if (fetchOptoins.Count != null)
            {
                crit.SetMaxResults(fetchOptoins.Count.Value);
            }
        }
Beispiel #3
0
        public ActionResult Index(GroupFilter filter, FetchOptoins fetchOptoins, int page = 0)
        {
            int pageSize = 5;

            if (page < 0)
            {
                page = 0;
            }

            fetchOptoins.First = page * pageSize;

            fetchOptoins.Count = pageSize;

            var model = new GroupListModel
            {
                Items       = groupRepository.Find(filter, fetchOptoins),
                CurrentPage = page,
            };

            return(View(model));
        }
Beispiel #4
0
        public ActionResult Index(long?parent, FetchOptoins fetchOptions)
        {
            Folder parentFolder = null;

            if (parent.HasValue)
            {
                parentFolder = folderRepository.Load(parent.Value);
            }

            var model = new FolderListModel
            {
                Items = folderRepository.Find(new FolderFilter {
                    Parent = parentFolder
                }, fetchOptions),
                CurrentFolder = parentFolder,
                Parent        = parentFolder != null ? parentFolder.Parent : null,
            };

            model.IsRootFolder = parent == null && model.Parent == null;
            return(View("Index", model));
        }