示例#1
0
        public async Task <CreateVotingResponseDto> CreateVoting(CreateVotingRequestDto voting)
        {
            Voting newVoting = new Voting
            {
                ID          = new Guid(),
                Name        = voting.Name,
                CreatedDate = DateTime.Now,
                Description = voting.Description,
                DueDate     = voting.DueDate,
                CategoryId  = voting.CategoryId
            };

            var addedVoting = await _votingRepository.AddAsync(newVoting);

            CreateVotingResponseDto response = new CreateVotingResponseDto
            {
                Name        = addedVoting.Name,
                Description = addedVoting.Description,
                CreatedDate = addedVoting.CreatedDate,
                DueDate     = addedVoting.DueDate,
                VotersCount = addedVoting.VotersCount
            };

            return(response);
        }
示例#2
0
        public async Task <ActionResult <CreateVotingResponseDto> > Create(CreateVotingRequestDto request)
        {
            var voting = await _service.CreateVoting(request);

            return(Ok(voting));
        }