Пример #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 Create(VotingViewModel voting)
        {
            var category = await _categoryRepository.GetCategoryById(voting.CategoryId);

            var _voting = new Voting
            {
                ID          = new Guid(),
                Name        = voting.Name,
                Description = voting.Description,
                CategoryId  = voting.CategoryId,
                DueDate     = voting.DueDate,
                VotersCount = 0,
                CreatedDate = DateTime.Now,
                Category    = category
            };

            await _votingRepository.AddAsync(_voting);
        }