示例#1
0
        public async Task <string> Handle(CreatePollRequest request, CancellationToken cancellationToken)
        {
            var(conferenceId, pollInstruction, pollConfig, initialState, roomId) = request;

            var pollId    = Guid.NewGuid().ToString("N");
            var timestamp = DateTimeOffset.UtcNow;
            var poll      = new Poll(pollId, pollInstruction, pollConfig, roomId, timestamp);

            await _repository.CreatePoll(conferenceId, poll);

            await _repository.SetPollState(conferenceId, pollId, initialState);

            if (!await _openConferenceRepository.IsOpen(request.ConferenceId))
            {
                await _repository.DeletePollAndState(conferenceId, pollId);

                throw ConferenceError.ConferenceNotOpen.ToException();
            }

            await _mediator.Send(new UpdateParticipantSubscriptionsOfPollRequest(conferenceId, poll));

            await SceneUpdater.UpdateScene(_mediator, conferenceId, roomId);

            return(pollId);
        }
        public PollVM Create(string dictaatName, [FromBody] PollVM poll)
        {
            if (!AuthorizeResource(dictaatName))
            {
                return(null);
            }

            return(_pollRepository.CreatePoll(dictaatName, poll));
        }
示例#3
0
        public ActionResult <PollDetailDto> CreatePoll(PollCreateDto pollCreateDto)
        {
            try
            {
                //Map Poll models properties to pollCreateDto
                var pollModel = _mapper.Map <Poll>(pollCreateDto);

                _repository.CreatePoll(pollModel);
                _repository.SaveChanges();

                //Map Poll models properties to PollDetailDto
                var pollReadDto = _mapper.Map <PollDetailDto>(pollModel);

                return(Ok(pollReadDto));
            }
            catch (Exception e)
            {
                return(StatusCode(500, "Poll creation error: " + e));
            }
        }