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()); }
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()); }
public int GetNumberOfRecords(FilterAdverts filterTasks, int categoryId) { return(_unitOfWork.Advert.GetNumberOfRecords(filterTasks, categoryId)); }
public IEnumerable <Advert> GetAdverts(FilterAdverts filterAdverts, PagingInfo pagingInfo, int categoryId) { return(_unitOfWork.Advert.GetAdverts(filterAdverts, pagingInfo, categoryId)); }