public Guid CreateVote(CreateVoteCommand command, string userId) { var vote = command.ToVote(userId); _context.Add(vote); _context.SaveChanges(); return(vote.Id); }
public async Task <IActionResult> Create(CreateVoteCommand command) { try { if (ModelState.IsValid) { var user = await GetCurrentUserAsync(); var id = _voteService.CreateVote(command, user.Id); return(RedirectToAction(nameof(Details), new { id = id })); } } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); } return(View(command)); }
public async Task <IActionResult> Create(CreateVoteCommand command) { return(Ok(await Mediator.Send(command))); }