public ActionResult <TalkDto> GetTalksForSpeaker(int speakerId, int talkId)
        {
            if (!_speakerRepository.SpeakerExists(speakerId))
            {
                return(NotFound());
            }

            var talkForSpeaker = _talkRepository.GetTalk(speakerId, talkId);

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

            return(Ok(_mapper.Map <TalkDto>(talkForSpeaker)));
        }
        public ActionResult <bool> ReserveSeat([FromRoute] int talkId, [FromBody] int userId)
        {
            // TODO: Requires errors
            var talk = talkRepository.GetTalk(talkId).Result;

            if (talk != null)
            {
                // TODO: For this to work completely, we will need atomic operations, and reactions on them
                if (talk.ParticipantIds.Count() < talk.Capacity)
                {
                    var registered = talkRepository.ReserveSeat(talkId, userId).Result;
                    return(registered);
                }
                else
                {
                    return(StatusCode(406, "Talk is at capacity"));
                }
            }
            return(NotFound());
        }
示例#3
0
 public Talk getTalkById(int id)
 {
     return(repo.GetTalk(id));
 }