Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="serchFilter"></param>
        /// <param name="pagenumber"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public static IPagedList<ApplicationModel> FilterApplicationList(string serchFilter, int pagenumber, int pagesize)
        {
            ApplicationSearchSettings settings = new ApplicationSearchSettings()
            {
                Orderby=Library.BLL.Enums.ApplicationFields.ApplicationName,
                PageNumber=pagenumber,
                PageSize=pagesize,
                SerchFilter=serchFilter
            };

            List<ApplicationModel> data = new List<ApplicationModel>();

            IPagedList<ApplicationEntity> queryResult = RepositoryContext.Current.Applications.Search(settings);

            foreach (ApplicationEntity ae in queryResult)
            {
                data.Add(EntityToModel(ae));
            }

            return new StaticPagedList<ApplicationModel>(data, pagenumber, pagesize,queryResult.TotalItemCount);
        }
Exemplo n.º 2
0
        public IPagedList<ApplicationEntity> Search(ApplicationSearchSettings searchSettings)
        {
            List<ApplicationEntity> entity;
            using (IUnitOfWork uow = _UnitFactory.GetUnit(this))
            {
                uow.BeginTransaction();
                if (string.IsNullOrEmpty(searchSettings.SerchFilter))
                {
                    entity = uow.Query<ApplicationEntity>().OrderBy(x => x.ApplicationName).ToList();
                }
                else
                {
                    entity = uow.Query<ApplicationEntity>().Where(x => x.ApplicationName.Contains(searchSettings.SerchFilter)).OrderBy(x => x.ApplicationName).ToList();
                }

                //foreach (ApplicationEntity e in entity)
                //{
                //    AppUserRoleEntity r = uow.Query<AppUserRoleEntity>().Where(x => (x.Role.RoleName == Constants.Roles.Admin || x.Role.RoleName == Constants.Roles.Write) && x.Application.IdApplication == e.IdApplication && x.User.Id == UserProfileContext.Current.User.Id).FirstOrDefault();
                //    if (UserProfileContext.Current.User.IsAdmin || r != null)
                //        data.Add(EntityToModel(e));
                //}
            }

            return new StaticPagedList<ApplicationEntity>(entity, searchSettings.PageNumber, searchSettings.PageSize, entity.Count);
        }