public IActionResult UpdatePriceRange(int startPrice, int endPrice) { try { _catalogService.ChangePriceRange(startPrice, endPrice); return(Ok()); } catch (Exception ex) { Console.WriteLine(ex.Message); return(StatusCode(500)); } }
public IActionResult Index(FilteredWatchViewModel filteredVM, int pageNum = 1) { if (filteredVM.PriceRange is null) { var priceRangeDTO = _catalogService.GetWatchesPriceRange(); filteredVM.PriceRange = _mapper.Map <PriceRangeViewModel>(priceRangeDTO); } else { _catalogService.ChangePriceRange(filteredVM.PriceRange.StartPrice, filteredVM.PriceRange.EndPrice); } var pagedResult = (filteredVM.Filter switch { Filter.OrderByPriceAsc => _catalogService.ReadOrderedByPriceAsc(), Filter.OrderByPriceDesc => _catalogService.ReadOrderedByPriceDesc(), Filter.SortByNoveltyAsc => _catalogService.ReadOrderedByNoveltyAsc(), Filter.SortByNoveltyDesc => _catalogService.ReadOrderedByNoveltyDesc(), Filter.SortByPopularityAsc => _catalogService.ReadOrderedByPopularityAsc(), Filter.SortByPopularityDesc => _catalogService.ReadOrderedByPopularityDesc(), _ => _catalogService.ReadAll() }).Select(_ => _mapper.Map <WatchViewModel>(_)).GetPaged(pageNum, filteredVM.ItemsOnPage);