public override async Task <Confirming> CreatingPassword(AccountId request, ServerCallContext context) { var query = new GetAccountByIdQuery(request.ToAccountId()); var account = await _mediator.Send(query, context.CancellationToken); if (account is null) { context.Status = new Status(StatusCode.NotFound, ElwarkExceptionCodes.AccountNotFound); return(new Confirming()); } if (account.IsPasswordAvailable()) { context.Status = new Status(StatusCode.InvalidArgument, ElwarkExceptionCodes.PasswordAlreadyCreated); return(new Confirming()); } var confirmationId = await _mediator.Send( new SendConfirmationCommand(account.Id, account.GetPrimaryEmail().GetIdentity(), _language), context.CancellationToken ); return(new Confirming { Id = confirmationId.ToString() }); }
public override async Task <ProfileReply> GetProfile(AccountId request, ServerCallContext context) { var data = await _mediator.Send(new GetAccountByIdQuery(request.ToAccountId()), context.CancellationToken); if (data is not null) { return(data.ToGatewayProfileReply()); } context.Status = new Status(StatusCode.NotFound, ElwarkExceptionCodes.AccountNotFound); return(new ProfileReply()); }