Пример #1
0
        public int GetNumberOfRecords(FilterAdverts filterTasks, int categoryId)
        {
            var adverts = _context.Adverts
                          .Include(x => x.Category).AsQueryable();

            if (filterTasks.IsActive == true)
            {
                adverts = adverts.Where(x => x.IsActive == filterTasks.IsActive);
            }

            if (filterTasks.CategoryId != 0)
            {
                adverts = adverts.Where(x => x.CategoryId == filterTasks.CategoryId);
            }

            if (categoryId != 0)
            {
                adverts = adverts.Where(x => x.CategoryId == categoryId);
            }

            if (!string.IsNullOrWhiteSpace(filterTasks.Title))
            {
                adverts = adverts.Where(x => x.Title.Contains(filterTasks.Title));
            }


            return(adverts.Count());
        }
Пример #2
0
        public IEnumerable <Advert> GetAdverts(FilterAdverts filterTasks, PagingInfo pagingInfo, int categoryId)
        {
            var adverts = _context.Adverts
                          .Include(x => x.Category).AsQueryable();

            if (filterTasks.IsActive == true)
            {
                adverts = adverts.Where(x => x.IsActive == filterTasks.IsActive);
            }

            if (filterTasks.CategoryId != 0)
            {
                adverts = adverts.Where(x => x.CategoryId == filterTasks.CategoryId);
            }

            if (categoryId != 0)
            {
                adverts = adverts.Where(x => x.CategoryId == categoryId);
            }

            if (!string.IsNullOrWhiteSpace(filterTasks.Title))
            {
                adverts = adverts.Where(x => x.Title.Contains(filterTasks.Title));
            }

            if (pagingInfo != null)
            {
                adverts = adverts
                          .Skip((pagingInfo.CurrentPage - 1) * pagingInfo.ItemsPerPage)
                          .Take(pagingInfo.ItemsPerPage);
            }

            return(adverts.OrderBy(x => x.StartDate).ToList());
        }
Пример #3
0
 public int GetNumberOfRecords(FilterAdverts filterTasks, int categoryId)
 {
     return(_unitOfWork.Advert.GetNumberOfRecords(filterTasks, categoryId));
 }
Пример #4
0
 public IEnumerable <Advert> GetAdverts(FilterAdverts filterAdverts, PagingInfo pagingInfo, int categoryId)
 {
     return(_unitOfWork.Advert.GetAdverts(filterAdverts, pagingInfo, categoryId));
 }