Example #1
0
        [DisableAuditing]//不添加日志
        public PagedResultOutput <PageElementQueryDto> GetPageElementQuery(GetPageElementQueryInput input)
        {
            if (input.MaxResultCount <= 0)
            {
                input.MaxResultCount = SettingManager.GetSettingValue <int>(MySettingProvider.QuestionsDefaultPageSize);
            }

            var query = _pageElementRepository.GetAll()
                        //TODO:根据传入的参数添加过滤条件
                        //.WhereIf(input.PageElementCategoryId.HasValue, m => m.PageElementCategoryId == input.PageElementCategoryId)
                        .WhereIf(input.ElementType != 0, m => m.ElementType == input.ElementType)
                        .WhereIf(input.PagesId != 0, m => m.PageId == input.PagesId)
                        .WhereIf(!input.Keywords.IsNullOrWhiteSpace(), m => m.Title.Contains(input.Keywords)).OrderBy(input.Sorting);
            var totalCount = query.Count();
            var list       = query.ToList();

            List <PageElementQueryDto> PageElementlist = new List <PageElementQueryDto>();

            foreach (PageElementQueryDto item in list.MapTo <List <PageElementQueryDto> >())
            {
                if (item.LastModifierUserId != null)
                {
                    User user = _userManager.Users.FirstOrDefault(u => u.Id == item.LastModifierUserId.Value);
                    item.UserName = user.UserName + "[" + item.LastModificationTime + "]";
                }
                item.StatusName      = AppEnum.GetBiStatus(item.Status);
                item.ElementTypeName = AppEnum.GetElementType(item.ElementType);
                item.Icon            = "<i class=\"fa fa-arrows\"></i>";
                PageElementlist.Add(item);
            }
            return(new PagedResultOutput <PageElementQueryDto>
            {
                TotalCount = totalCount,
                Items = PageElementlist
            });
        }