Пример #1
0
        public IEnumerable <OfferViewModel> GetOffers()
        {
            var entities = repository.FindAll();
            var models   = mapper.Map <IEnumerable <OfferEntity>, IEnumerable <OfferViewModel> >(entities);

            return(models);
        }
Пример #2
0
 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}"));
            }
        }