public async Task <IActionResult> GetAllProducts() { var products = await _repo.GetAllProducts(); var productsToReturn = _mapper.Map <IEnumerable <ProductForListDto> >(products); return(Ok(productsToReturn)); }
public IActionResult Get() { try { //Return 200 return(Ok(shoppingRepo.GetAllProducts())); } catch (Exception ex) { logger.LogError("Failed to get products,{0}", ex); return(BadRequest("Sorry! Server failed to get products, please try again later.")); } }
public IActionResult Shop() { try { var result = Mapper.Map <IEnumerable <Product>, IEnumerable <ProductViewModel> >(rep.GetAllProducts()); return(View(result)); } catch (Exception ex) { this.Logger.LogError(ex.Message); return(null); } }
public IActionResult Shop() { var result = repository.GetAllProducts(); return(View(result)); }