Ejemplo n.º 1
0
        public IActionResult Index(IndexModel indexModel)
        {
            if (indexModel.SearchingString == null)
            {
                var bikes     = _repo.GetProducts();
                var bikesCard = bikes.Select(b => _mapper.Map <BikeCardViewModel>(b));
                var model     = new IndexModel()
                {
                    SearchingString = indexModel.SearchingString,
                    bikesList       = bikesCard
                };
                return(View(model));
            }

            var searchBikes = _repo.GetProducts(indexModel.SearchingString);
            var searchModel = new IndexModel()
            {
                SearchingString = indexModel.SearchingString,
                bikesList       = searchBikes.Select(b => _mapper.Map <BikeCardViewModel>(b))
            };

            return(View(searchModel));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetProducts(int rq, int c)
        {
            if (rq * c < 0)
            {
                return(BadRequest("Mənfi sorğu nömrəsi və ya səhifəlik məhsul sayı daxil edilib."));
            }

            var result = await _repo.GetProducts(rq, c);

            if (result.IsSucces)
            {
                return(Ok(result.Content));
            }

            return(StatusCode(520, result.Message));
        }
Ejemplo n.º 3
0
 public IEnumerable <Products> Get()
 {
     return(_productsRepo.GetProducts().ToArray());
 }