Esempio n. 1
0
        public async Task CreateNewPoll(PollCreationRequest request)
        {
            try
            {
                if (request.StartsAt < DateTime.UtcNow)
                {
                    throw new InvalidPollException("Start time expired");
                }

                var pollObj = new Poll()
                {
                    PollId    = Guid.NewGuid(),
                    PollOwner = request.PollOwner,
                    CreatedAt = DateTime.UtcNow,
                    StartAt   = request.StartsAt,
                    EndAt     = request.EndsAt
                };

                var pollContentObj = new PollContent()
                {
                    PollId       = pollObj.PollId,
                    PollQuestion = request.PollQuestion,
                    Options      = request.Options
                };

                await _pollRepository.CreatePollAsync(pollObj);

                await _pollRepository.CreatePollContentAsync(pollContentObj);
            }
            catch (Exception)
            {
                throw;
            }
        }