Esempio n. 1
0
        public async Task <IActionResult> Add([FromForm] CreateVotingDto dto)
        {
            if (ModelState.IsValid)
            {
                int createdVotingId = await _votingService.AddAsync(dto, User);

                return(RedirectToAction("Get", new { id = createdVotingId }));
            }

            return(View(dto));
        }
Esempio n. 2
0
        public async Task <int> AddAsync(CreateVotingDto dto, ClaimsPrincipal user)
        {
            var voting = _mapper.Map <Voting>(dto);

            voting.UserId = user.GetUserId();

            voting.Chat = new Chat();

            _unitOfWork.VotingRepository.Create(voting);

            await _unitOfWork.SaveChangesAsync();

            return(voting.Id);
        }