Exemplo n.º 1
0
 public Database.Entities.Other.Poll Convert(Models.Other.CRUD.Poll source, Database.Entities.Other.Poll destination, ResolutionContext context)
 {
     return(new Database.Entities.Other.Poll
     {
         Name = source.Name,
         Slug = new SlugHelper().GenerateSlug(source.Name),
         CreatedByUserId = source.CreatedByUserId,
         Created = DateTime.Now
     });
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
 public Task <List <Result> > Create([FromBody] Models.Other.CRUD.Poll poll)
 {
     _logger.Debug("Requesting to create a new poll");
     return(_pollRepository.CreateNewPollAsync(poll));
 }