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)); }
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); }