public IActionResult Index() { var results = _repository.GetAllAdvertisements(); return(View(_mapper.Map <IEnumerable <Advertisement>, IEnumerable <AdvertisementViewModel> >(results))); }
public ActionResult <IEnumerable <Advertisement> > Get() { try { return(Ok(_mapper.Map <IEnumerable <Advertisement>, IEnumerable <AdvertisementViewModel> >(_repository.GetAllAdvertisements()))); } catch (Exception ex) { _logger.LogError($"Falied to get advertisements: {ex}"); return(BadRequest("Falied to get advertisements")); } }