public async Task <OperationResult <bool> > IsUsernameUniqueAsync(VerifyUsernameUniqueRequest request, CancellationToken cancellationToken) { var response = await _mediator.Send(request, cancellationToken) .ConfigureAwait(false); return(response); }
public async Task <OperationResult <bool> > Handle(VerifyUsernameUniqueRequest message, CancellationToken cancellationToken) { using (var context = _companyContextFactory()) { var username = message.Username.ToUpper(); var isUnique = !await context.Users.AnyAsync(x => username == x.Username.ToUpper(), cancellationToken) .ConfigureAwait(false); return(OperationResultBuilder.CreateSuccess(isUnique)); } }
private async Task <bool> BeUniqueUsernameAsync(string username, CancellationToken cancellationToken) { var request = new VerifyUsernameUniqueRequest { Username = username }; var response = await _userService.IsUsernameUniqueAsync(request, cancellationToken) .ConfigureAwait(false); return(response.Result); }