public PagedResponse <PerfumeDto> Execute(PerfumeSearch search) { var query = _context.Perfumes .Include(x => x.Brand) .AsQueryable(); if (search.FragranceTypeId > 0) { query = query.Where(x => x.FragranceTypeId == search.FragranceTypeId); } if (!string.IsNullOrEmpty(search.Name) || !string.IsNullOrWhiteSpace(search.Name)) { query = query.Where(x => (x.Fragrance.ToLower().Contains(search.Name.ToLower())) || (x.Brand.Name.ToLower().Contains(search.Name.ToLower()))); } return(query.MakePaged <PerfumeDto, Perfume>(search, _mapper)); }
public PagedResponse <PerfumeDto> Execute(PerfumeSearch search) { var query = _context.Perfumes .Include(x => x.Brand) .AsQueryable(); if (!string.IsNullOrEmpty(search.Name) || !string.IsNullOrWhiteSpace(search.Name)) { query = query.Where(x => (x.Fragrance.ToLower().Contains(search.Name.ToLower())) || (x.Brand.Name.ToLower().Contains(search.Name.ToLower()))); } if (search.PriceAsc) { query = query.OrderBy(x => x.Price - (x.Price / 100 * x.Discount)); } else if (!search.PriceAsc) { query = query.OrderByDescending(x => x.Price - (x.Price / 100 * x.Discount)); } return(query.MakePaged <PerfumeDto, Perfume>(search, _mapper)); }
public IActionResult Get(int genderid, [FromQuery] PerfumeSearch search, [FromServices] IGetPerfumesByGender query) { search.GenderId = genderid; return(Ok(_executor.ExecuteQuery(query, search))); }
public IActionResult Get([FromQuery] PerfumeSearch search, [FromServices] IGetPerfumesQuery query) { return(Ok(_executor.ExecuteQuery(query, search))); }
public IActionResult Get(int id, [FromQuery] PerfumeSearch search, [FromServices] IGetPerfumesByFragranceType query) { search.FragranceTypeId = id; return(Ok(_executor.ExecuteQuery(query, search))); }