Exemple #1
0
        [HttpGet("getspecific/{id}", Name = "CampGetSpecific")] //LD STEP100
        public IActionResult GetSpecific(int id, bool includeSpeakers = false)
        {
            try
            {
                Camp camps = null;

                if (includeSpeakers)
                {
                    camps = _repo.GetCampWithSpeakers(id);
                }
                else
                {
                    camps = _repo.GetCamp(id);
                }

                if (camps == null)
                {
                    return(NotFound($"Camp {id} was not found"));
                }

                _logger.LogInformation("LD GET REQUEST DONE");
                return(Ok(camps));
            }
            catch
            {
            }
            return(BadRequest());//LD default return
        }
Exemple #2
0
        public IActionResult Get(int id, bool includeSpeakers = false)
        {
            try
            {
                Camp camp = null;

                if (includeSpeakers)
                {
                    camp = _repo.GetCampWithSpeakers(id);
                }
                else
                {
                    camp = _repo.GetCamp(id);
                }

                if (camp == null)
                {
                    return(NotFound($"Camp {id} was not found"));
                }
                return(Ok(_mapper.Map <CampModel>(camp, opt => opt.Items["UrlHelper"] = this.Url)));
            }
            catch
            {
            }
            return(BadRequest());
        }
        public IActionResult Get(int id, bool includeSpeakers = false)
        {
            try
            {
                Camp camp;
                if (includeSpeakers)
                {
                    camp = _camp.GetCampWithSpeakers(id);
                }
                else
                {
                    camp = _camp.GetCamp(id);
                }

                if (camp == null)
                {
                    return(NotFound($"Camp {id} was not found in Azure new build/deployment"));
                }
                return(Ok(_mapper.Map <CampModel>(camp)));
            }
            catch
            {
            }
            return(BadRequest());
        }
        public IActionResult Get(int id, bool includeSpeakers = false)
        {
            try
            {
                Camp camp = null;

                if (includeSpeakers)
                {
                    camp = _repo.GetCampWithSpeakers(id);
                }
                else
                {
                    camp = _repo.GetCamp(id);
                }

                if (camp == null)
                {
                    return(NotFound($"Camp {id} was not found"));
                }
                return(Ok(camp));
            }
            catch
            {
            }

            return(BadRequest());
        }
Exemple #5
0
        public IActionResult Get(int id, bool includeSpeaker = false)
        {
            var camp = includeSpeaker ? _reposetory.GetCampWithSpeakers(id) : _reposetory.GetCamp(id);

            if (camp == null)
            {
                return(NotFound("camp not found "));
            }
            return(Ok(_mapper.Map <CampsModel>(camp)));
        }
Exemple #6
0
        public IActionResult Get(int id, bool includeSpeakers = false)
        {
            var camp = includeSpeakers ?
                       _campRepository.GetCampWithSpeakers(id) :
                       _campRepository.GetCamp(id);

            if (camp == null)
            {
                return(NotFound($"Camp {id} was not found"));
            }

            return(Ok(_mapper.Map <CampModel>(camp)));
        }
        public IActionResult Get(int id, bool includeSpeakers = false)
        {
            try
            {
                Camp camp = null;
                if (includeSpeakers)
                {
                    camp = _campRepository.GetCampWithSpeakers(id);
                }
                else
                {
                    camp = _campRepository.GetCamp(id);
                }
                if (camp == null)
                {
                    return(NotFound($"Camp {id} was not found"));
                }

                //return Ok(camp);
                return(Ok(Mapper.Map <CampModel>(camp)));
                //return Ok(Mapper.Map<CampModel>(camp, opt => opt.Items["UrlHelper"] = this.Url));
            }
            catch (Exception e)
            {
                _logger.LogInformation(e.Message);
                return(BadRequest());
            }
        }
Exemple #8
0
        public async Task <CampViewModel> GetCamp(string moniker)
        {
            var entity = await _repository.GetCamp(moniker);

            CampViewModel campViewModel = _mapper.Map <CampViewModel>(entity);

            return(campViewModel);
        }
Exemple #9
0
        public IActionResult Get(int id, bool includeSpeakers = false)
        {
            try {
                var camp = includeSpeakers
                    ? _campRepository.GetCampWithSpeakers(id)
                    : _campRepository.GetCamp(id);
                if (camp == null)
                {
                    return(NotFound($"Camp with id '{id}' was not found."));
                }
                return(Ok(camp));
            } catch (Exception ex) {
                _logger.LogCritical($"Threw exception while getting camp with id='{id}' and includeSpeakers='{includeSpeakers}': {ex}");
            }

            return(BadRequest("Could not get camp"));
        }
Exemple #10
0
        public IActionResult Get(int id)
        {
            var camp = _repo.GetCamp(id);

            if (camp == null)
            {
                return(NotFound());
            }
        }
Exemple #11
0
        public async Task <ActionResult <Camp> > GetCamp(int id)
        {
            try
            {
                var camp = await _campRepository.GetCamp(id);

                if (camp == null)
                {
                    return(NotFound());
                }

                return(camp);
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error in Retrieving Data from  Database"));
            }
        }
Exemple #12
0
        public IActionResult Get(int id, bool includeSpeakers = false)
        {
            try {
                var camp = includeSpeakers
                    ? _campRepository.GetCampWithSpeakers(id)
                    : _campRepository.GetCamp(id);
                if (camp == null)
                {
                    return(NotFound($"Camp with id '{id}' was not found."));
                }
                return(Ok(camp));
            } catch { }

            return(BadRequest());
        }
Exemple #13
0
        public async Task <IActionResult> Post(int campId, [FromBody] SpeakerModel model)
        {
            var camp = _campRepository.GetCamp(campId);

            if (camp == null)
            {
                return(BadRequest("No camp found"));
            }

            var speaker = _mapper.Map <Speaker>(model);

            speaker.Camp = camp;

            _campRepository.Add(speaker);
            await _campRepository.SaveAllAsync();

            var url = Url.Link("SpeakerGet", new { campId = camp.Id, speakerId = speaker.Id });

            return(Created(url, _mapper.Map <SpeakerModel>(speaker)));
        }