public IActionResult Get() { var camps = _reposotory.GetAllCamps(); return(Ok(_mapper.Map <IEnumerable <CampModel> >(camps))); }
public async Task <List <CampViewModel> > GetAllCamps() { var listEntity = await _repository.GetAllCamps(); List <CampViewModel> listViewModel = _mapper.Map <List <CampViewModel> >(listEntity); return(listViewModel); }
public IActionResult Get() { //Logger.LogInformation("All camps request"); var camps = _campRepository.GetAllCamps(); return(Ok(_mapper.Map <IEnumerable <CampModel> >(camps))); }
public IActionResult Get() { try { var camps = _campRepository.GetAllCamps(); return(Ok(camps)); } catch { } return(BadRequest()); }
public IActionResult Get() { var camps = _reposetory.GetAllCamps(); if (camps == null) { return(NotFound($"Camps not found ")); } return(Ok(_mapper.Map <IEnumerable <CampsModel> >(camps))); }
public IActionResult Get() { var camps = _camp.GetAllCamps(); //With automapper, convert Camps to IEnumerable of CampsModel objects //automatically maps properties and flattens inner objects like Location and Speakers //Automapper is injected in the comptroller and the startup class //Need to create a profile class to map entities return(Ok(_mapper.Map <IEnumerable <CampModel> >(camps))); }
public IActionResult Get() { try { var camps = _campRepository.GetAllCamps(); return(Ok(camps)); } catch (Exception ex) { _logger.LogCritical($"Threw exception while getting camps: {ex}"); } return(BadRequest("Could not get camps")); }
public IActionResult Get() { try { var camps = _campRepository.GetAllCamps(); // return Ok(_mapper.Map<IEnumerable<CampViewModel>>(camps, opt => opt.Items["UrlHelper"] = Url)); /* => this method was cumbersome to use, now implemented by custom resolver */ return(Ok(_mapper.Map <IEnumerable <CampViewModel> >(camps))); } catch (Exception ex) { _logger.LogCritical($"Threw exception while getting camps: {ex}"); } return(BadRequest("Could not get camps")); }
public async Task <ActionResult <CampModel[]> > Get(bool includeTalks = false) { try { var results = await campRepository.GetAllCamps(includeTalks); return(mapper.Map <CampModel[]>(results)); } catch (Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } }
public IActionResult Get() { try { var camps = _campRepository.GetAllCamps(); //return Ok(camps); return(Ok(Mapper.Map <IEnumerable <CampModel> >(camps))); } catch (Exception e) { _logger.LogInformation(e.Message); return(BadRequest()); } }
public ActionResult <IEnumerable <CampModel> > Get() { try { IEnumerable <Camp> result = _repository.GetAllCamps(); return(Ok(_mapper.Map <IEnumerable <CampModel> >(result))); } catch (Exception) { } return(BadRequest()); }
public IActionResult Get() { var camps = _repo.GetAllCamps(); return(Ok(camps)); }