Beispiel #1
0
        public async Task <List <Result> > CreateNewPollAsync(Models.Other.CRUD.Poll poll)
        {
            var newPoll = _mapper.Map <Database.Entities.Other.Poll>(poll);

            var isCreated = _dbClient.CreatePollAsync(newPoll);
            var results   = await new List <Result>().Get(isCreated, ResultMessages.CreatePoll);

            if (!await isCreated)
            {
                return(results);
            }

            var selections = _mapper.Map <List <Database.Entities.Other.PollSelection> >(poll.Selections);

            foreach (var selection in selections)
            {
                selection.PollId = newPoll.Id;
            }
            await _dbClient.CreatePollSelectionsAsync(selections);

            return(results);
        }