예제 #1
0
        public IActionResult Get()
        {
            var camps = _reposotory.GetAllCamps();


            return(Ok(_mapper.Map <IEnumerable <CampModel> >(camps)));
        }
예제 #2
0
        public async Task <List <CampViewModel> > GetAllCamps()
        {
            var listEntity = await _repository.GetAllCamps();

            List <CampViewModel> listViewModel = _mapper.Map <List <CampViewModel> >(listEntity);

            return(listViewModel);
        }
예제 #3
0
        public IActionResult Get()
        {
            //Logger.LogInformation("All camps request");

            var camps = _campRepository.GetAllCamps();

            return(Ok(_mapper.Map <IEnumerable <CampModel> >(camps)));
        }
예제 #4
0
        public IActionResult Get()
        {
            try {
                var camps = _campRepository.GetAllCamps();
                return(Ok(camps));
            } catch { }

            return(BadRequest());
        }
예제 #5
0
        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)));
        }
예제 #7
0
        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"));
        }
예제 #8
0
        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"));
        }
예제 #9
0
        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"));
            }
        }
예제 #10
0
 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());
     }
 }
예제 #11
0
        public ActionResult <IEnumerable <CampModel> > Get()
        {
            try
            {
                IEnumerable <Camp> result = _repository.GetAllCamps();

                return(Ok(_mapper.Map <IEnumerable <CampModel> >(result)));
            }
            catch (Exception)
            {
            }

            return(BadRequest());
        }
예제 #12
0
        public IActionResult Get()
        {
            var camps = _repo.GetAllCamps();

            return(Ok(camps));
        }