Ejemplo n.º 1
0
        [DisableAuditing]//不添加日志
        public PageDto GetPageForIndex(GetPageQueryInput input)
        {
            var page = this.GetCachePageList();

            page = page.Where(p => p.PageType == (int)AppEnum.PageType.HomePage && p.StoreId == Convert.ToInt32(input.StoreId) && p.PagePosition == 2 && p.Status == (int)AppEnum.PageStatus.Show).OrderBy(p => p.SortNum).ToList();

            if (page.Count <= 0)
            {
                throw new UserFriendlyException("");
            }

            return(page[0]);
        }
Ejemplo n.º 2
0
        [DisableAuditing]//不添加日志
        public PagedResultOutput <PageQueryDto> GetPageQuery(GetPageQueryInput input)
        {
            if (input.MaxResultCount <= 0)
            {
                input.MaxResultCount = SettingManager.GetSettingValue <int>(MySettingProvider.QuestionsDefaultPageSize);
            }

            var query = _pageRepository.GetAll()
                        //TODO:根据传入的参数添加过滤条件
                        .WhereIf(input.Status != 0, m => m.Status == input.Status)
                        .WhereIf(input.PageType != 0, m => m.PageType == input.PageType)
                        .WhereIf(input.StoreId != 0, m => m.StoreId == input.StoreId)
                        .WhereIf(!input.Keywords.IsNullOrWhiteSpace(), m => m.Name.Contains(input.Keywords)).OrderBy(input.Sorting);
            var totalCount = query.Count();
            var list       = query.PageBy(input).ToList();
            List <PageQueryDto> Pagelist = new List <PageQueryDto>();

            foreach (PageQueryDto item in list.MapTo <List <PageQueryDto> >())
            {
                User user = _userManager.Users.FirstOrDefault(u => u.Id == item.CreatorUserId.Value);
                item.UserName = user.UserName;
                if (item.StoreId != null && item.StoreId != "0")
                {
                    item.StoreId = _storeAppService.GetStores(Convert.ToInt32(item.StoreId)).Title;
                }
                item.PageTypeName     = AppEnum.GetPageType(item.PageType);
                item.StatusName       = AppEnum.GetPageStatus(item.Status);
                item.PagePositionName = AppEnum.GetPagePosition(item.PagePosition);
                Pagelist.Add(item);
            }
            return(new PagedResultOutput <PageQueryDto>
            {
                TotalCount = totalCount,
                Items = Pagelist
            });
        }