public IEnumerable <OfferViewModel> GetOffers() { var entities = repository.FindAll(); var models = mapper.Map <IEnumerable <OfferEntity>, IEnumerable <OfferViewModel> >(entities); return(models); }
public Task <List <Offer> > GetAllOffers() { try { return(_offerRepository.FindAll().OrderByDescending(offer => offer.Price).ToListAsync()); } catch (Exception ex) { throw new Exception(ex.ToString()); } }
public async Task <IActionResult> GetOffers() { var location = GetControllerActionNames(); try { _logger.LogInfo($"{location}: Attempted Call"); var offers = await _offerRepository.FindAll(); var response = _mapper.Map <IList <OfferDTO> >(offers); _logger.LogInfo($"{location}: Successful"); return(Ok(response)); } catch (Exception e) { return(InternalError($"{location}: {e.Message} - {e.InnerException}")); } }