Exemplo n.º 1
0
        public async Task <IActionResult> GetUsers([FromQuery] PaginateParams paginateParams, [FromQuery] string query)
        {
            var users = _repo.GetAll()
                        .ProjectTo <UserForModeratorView>(_mapper.ConfigurationProvider);
            var filtered = users.Where(x => x.Email.Contains(query ?? "") || x.UserName.Contains(query ?? ""));
            var pageData = await Paged <UserForModeratorView> .Paginate(filtered, paginateParams);

            return(Ok(pageData));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Get([FromQuery] AnnoucementFilter filterOptions,
                                              [FromQuery] PaginateParams paginateParams, [FromQuery] OrderParams orderParams)
        {
            var brands = _repo.GetAll().OrderBy(x => x.Title).Include(x => x.BrandCategories).ThenInclude(x => x.Category)
                         .Select(x => new BrandForViewDto
            {
                BrandId    = x.BrandId,
                Title      = x.Title,
                Categories = x.BrandCategories.Select(x => x.Category.Title)
            });
            var filtered      = brands.Where(x => x.Title.Contains(filterOptions.Query ?? ""));
            var paginatedData = await Paged <BrandForViewDto> .Paginate(filtered, paginateParams);

            return(Ok(paginatedData));
        }
Exemplo n.º 3
0
        public async Task <Paged <AnnoucementForViewDto> > GetAnnoucements(AnnoucementFilter filterOptions,
                                                                           PaginateParams paginateParams, OrderParams orderParams)
        {
            var annoucements = _repo.GetAll();
            IQueryable <AnnoucementForViewDto> annoucementsDto = annoucements.ProjectTo <AnnoucementForViewDto>(_mapper.ConfigurationProvider);
            var filteredAnnoucements = annoucementsDto.ApplySeachQuery(filterOptions);

            if (filteredAnnoucements.Count() > 0)
            {
                var orderedAnnoucements = filteredAnnoucements.OrderAnnoucements(orderParams);
                var pageData            = await Paged <AnnoucementForViewDto> .Paginate(orderedAnnoucements, paginateParams);

                return(pageData);
            }
            else
            {
                return(null);
            }
        }