Initial commit: NexusArchitect Professional Workstation Overhaul
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
using NexusReader.Application.Abstractions.Messaging;
|
||||
|
||||
namespace NexusReader.Application.Commands.Quiz;
|
||||
|
||||
public record SubmitAnswerCommand(int SelectedIndex, int CorrectIndex) : ICommand;
|
||||
@@ -0,0 +1,26 @@
|
||||
using FluentResults;
|
||||
using NexusReader.Application.Abstractions.Messaging;
|
||||
using NexusReader.Application.Abstractions.Services;
|
||||
|
||||
namespace NexusReader.Application.Commands.Quiz;
|
||||
|
||||
internal sealed class SubmitAnswerCommandHandler : ICommandHandler<SubmitAnswerCommand>
|
||||
{
|
||||
private readonly IPlatformService _platformService;
|
||||
|
||||
public SubmitAnswerCommandHandler(IPlatformService platformService)
|
||||
{
|
||||
_platformService = platformService;
|
||||
}
|
||||
|
||||
public async Task<Result> Handle(SubmitAnswerCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (request.SelectedIndex == request.CorrectIndex)
|
||||
{
|
||||
await _platformService.VibrateAsync(50);
|
||||
return Result.Ok();
|
||||
}
|
||||
|
||||
return Result.Fail("Incorrect answer.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user