コード例 #1
0
        public FoodMenuWithPagingSpecification(FoodMenuParams queryParams)
            : base(x =>
                   (
                       string.IsNullOrEmpty(queryParams.Search) ||
                       x.Content.ToLower().Contains(queryParams.Search) ||
                       x.User.FirstName.ToLower().Contains(queryParams.Search) ||
                       x.User.LastName.ToLower().Contains(queryParams.Search)

                   ) &&
                   (!queryParams.ScreenId.HasValue || x.FoodMenuSubScreens.Any(y => y.ScreenId == queryParams.ScreenId)) &&
                   (!queryParams.SubScreenId.HasValue || x.FoodMenuSubScreens.Any(y => y.SubScreenId == queryParams.SubScreenId)) &&
                   (!queryParams.Reject.HasValue || x.Reject == queryParams.Reject) &&
                   (!queryParams.IsNew.HasValue || x.IsNew == queryParams.IsNew) &&
                   (!queryParams.IsPublish.HasValue || x.IsPublish == queryParams.IsPublish)
                   )
        {
            AddInclude(x => x.FoodMenuPhotos);
            AddInclude(x => x.FoodMenuSubScreens);
            AddInclude(x => x.User);
            AddInclude(x => x.User.Campus);
            AddInclude(x => x.User.Degree);
            AddInclude(x => x.User.Department);
            AddOrderByDscending(x => x.IsNew);
            ApplyPaging(queryParams.PageSize * (queryParams.PageIndex - 1), queryParams.PageSize);
        }
コード例 #2
0
 public FoodMenuByUserIdSpecification(FoodMenuParams queryParams, int userId)
     : base(x => x.UserId == userId)
 {
     AddInclude(x => x.User);
     AddInclude(x => x.FoodMenuPhotos);
     AddOrderByDscending(x => x.Created);
     ApplyPaging(queryParams.PageSize * (queryParams.PageIndex - 1), queryParams.PageSize);
 }
        public FoodMenuWithFilterForCountAsyncSpecification(FoodMenuParams queryParams)
            : base(x =>
                   (
                       string.IsNullOrEmpty(queryParams.Search) ||
                       x.Content.ToLower().Contains(queryParams.Search) ||
                       x.User.FirstName.ToLower().Contains(queryParams.Search) ||
                       x.User.LastName.ToLower().Contains(queryParams.Search)

                   ) &&
                   (!queryParams.ScreenId.HasValue || x.FoodMenuSubScreens.Any(y => y.ScreenId == queryParams.ScreenId)) &&
                   (!queryParams.SubScreenId.HasValue || x.FoodMenuSubScreens.Any(y => y.SubScreenId == queryParams.SubScreenId)) &&
                   (!queryParams.Reject.HasValue || x.Reject == queryParams.Reject) &&
                   (!queryParams.IsNew.HasValue || x.IsNew == queryParams.IsNew) &&
                   (!queryParams.IsPublish.HasValue || x.IsPublish == queryParams.IsPublish)
                   )
        {
        }
コード例 #4
0
        // [SecuredOperation("Sudo,FoodMenu.List,FoodMenu.All", Priority = 1)]
        public async Task <Pagination <FoodMenuForReturnDto> > GetListAsync(FoodMenuParams queryParams)
        {
            var spec         = new FoodMenuWithPagingSpecification(queryParams);
            var listFromRepo = await foodMenuDal.ListEntityWithSpecAsync(spec);

            var countSpec = new FoodMenuWithFilterForCountAsyncSpecification(queryParams);
            var totalItem = await foodMenuDal.CountAsync(countSpec);


            var data = mapper.Map <List <FoodMenu>, List <FoodMenuForReturnDto> >(listFromRepo);

            return(new Pagination <FoodMenuForReturnDto>
                   (
                       queryParams.PageIndex,
                       queryParams.PageSize,
                       totalItem,
                       data
                   ));
        }
コード例 #5
0
 public async Task <ActionResult <Pagination <FoodMenuForReturnDto> > > List([FromQuery] FoodMenuParams queryParams)
 {
     return(await foodMenuService.GetListAsync(queryParams));
 }