public async Task <IAggregateRoot> ExecuteAsync(Command command) { AccountAggregate account = await _aggregateStore.GetByIdAsync <AccountAggregate>(command.AccountId); var response = await _telegramClient.SystemService.AddSessionAsync(account.Id.ToString()); if (response.IsSuccess) { account.CreateSession(); return(account); } account.FailSetup(response.Errors.Select(e => e.Message)); return(account); }
public async Task <IAggregateRoot> ExecuteAsync(Command command) { AccountAggregate account = await _aggregateStore.GetByIdAsync <AccountAggregate>(command.AccountId); ResponseWrapper response = await _telegramClient.UserService.PhoneLoginAsync(account.Id.ToString(), account.ExternalAccountId); if (response.IsSuccess) { account.SendCode(); return(account); } account.FailSetup(response.Errors.Select(e => e.Message)); return(account); }
public async Task <IAggregateRoot> ExecuteAsync(Command command) { AccountAggregate account = await _aggregateStore.GetByIdAsync <AccountAggregate>(command.AccountId); if (account.State != AccountAggregate.AccountState.WaitForCode) { throw new ValidationException("Not waiting for a code"); } ResponseWrapper response = await _telegramClient.UserService.CompletePhoneLoginAsync(account.Id.ToString(), command.Code); if (response.IsSuccess) { account.Verify(); return(account); } account.FailSetup(response.Errors.Select(e => e.Message)); return(account); }