public IActionResult GetRatings(int itemId) { try { //throw new Exception("e example"); if (!_itemInfoRepository.ItemExists(itemId)) { _logger.LogInformation($"Item with Id {itemId} wasn't found when accessing ratings"); return(NotFound()); } var ratingsForItem = _itemInfoRepository.GetRatingsForItem(itemId); //var ratingsForItemResults = new List<RatingDto>(); //foreach (var rating in ratingsForItem) //{ // ratingsForItemResults.Add(new RatingDto() // { // Id = rating.Id, // Name = rating.Name, // Description = rating.Description // }); //} //return Ok(ratingsForItemResults); return(Ok(_mapper.Map <IEnumerable <RatingDto> >(ratingsForItem))); } catch (Exception e) { _logger.LogCritical($"Exception while getting points of interest for item with id {itemId}", e); return(StatusCode(500, "A problem happened while handling your request")); } }