public async Task <ICommandResult <int> > HandleAsync(ExamStartAttemptCommand command) { var newAttempt = new ExamAttempt() { ExamId = command.ExamId, StartedAt = DateTime.Now, Started = true, Terminated = false, UserId = command.UserId }; _context.ExamAttempt.Add(newAttempt); await _context.SaveChangesAsync(); return(CommandResult <int> .Success(newAttempt.Id)); }
public async Task <IActionResult> StartAttempt(ExamStartAttemptCommand command) { var id = await _commandBus.ExecuteAsync <int>(command); return(Ok(id)); }