Ejemplo n.º 1
0
        public async Task <IActionResult> GetSpeakerTalks(string moniker, int id)
        {
            try
            {
                var speaker = await _repo.GetSpeakerAsync(id);

                foreach (var t in speaker.Talks)
                {
                    t.Speaker = null;                      // Trim Speaker when returning just the talks
                }
                return(Ok(_mapper.Map <IEnumerable <TalkViewModel> >(speaker.Talks)));
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed to get speaker's talks: {0}", ex);
            }

            return(BadRequest("Couldn't load talk."));
        }
        public async Task <IActionResult> Get(string moniker, int id)
        {
            try
            {
                return(Ok(_mapper.Map <SpeakerViewModel>(await _repo.GetSpeakerAsync(id))));
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed to get speaker: {0}", ex);
            }

            return(BadRequest("Failed to get Speakers"));
        }