コード例 #1
0
ファイル: HzAccountManger.cs プロジェクト: Veraatversus/HZBot
 /// <summary>Removes the account.</summary>
 /// <param name="account">The account.</param>
 public static void RemoveAccount(HzAccount account)
 {
     if (account != null && RemoveAccountCommand.CanExecute(account))
     {
         account.IsLogined = false;
         SynContext.Send((o) => Accounts.Remove(account), null);
     }
 }
コード例 #2
0
        public async Task <MutationInfo> Remove([Inject] IMediator mediator, [Inject] IRequestInfo requestInfo, NonNull <RemoveAccountParameters> parameters)
        {
            var command = new RemoveAccountCommand
            {
                Id      = parameters.Value.Id,
                Headers = new CommandHeaders(correlationId: Guid.NewGuid(), identity: requestInfo.Identity, remoteIpAddress: requestInfo.IpAddress)
            };

            var result = await mediator.Send(command);

            return(MutationInfo.FromCommand(command));
        }
コード例 #3
0
        public async Task Handle(RemoveAccountCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return;
            }

            var result = await _userService.RemoveAccountAsync(request);

            if (result)
            {
                await Bus.RaiseEvent(new AccountRemovedEvent(request.Id.Value));
            }
        }
コード例 #4
0
        public async Task <bool> RemoveAccountAsync(RemoveAccountCommand request)
        {
            var user = await _userManager.FindByNameAsync(request.Username);

            var result = await _userManager.DeleteAsync(user);

            if (result.Succeeded)
            {
                return(true);
            }

            foreach (var error in result.Errors)
            {
                await _bus.RaiseEvent(new DomainNotification(result.ToString(), error.Description));
            }

            return(false);
        }
コード例 #5
0
        public async Task DontRemoveAccount()
        {
            var command = new RemoveAccountCommand
            {
                AccountIds = new List <Guid>
                {
                    Guid.NewGuid()
                }
            };

            _db.Setup(x => x.SaveChangesAsync()).ReturnsAsync(0);

            var result = await _handler.Execute(command);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.EffectiveRows, 0);
            Assert.AreEqual(_accounts.Count, 1);
        }
コード例 #6
0
        public async Task RemoveExistingAccount()
        {
            var command = new RemoveAccountCommand
            {
                AccountIds = new List <Guid>
                {
                    new Guid("714b19c9-7c5b-47f9-9a99-46639db1595d")
                }
            };

            _db.Setup(x => x.SaveChangesAsync()).ReturnsAsync(1);

            var result = await _handler.Execute(command);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.EffectiveRows, 1);
            Assert.AreEqual(_accounts.Count, 0);
        }
コード例 #7
0
 public async Task <RemoveAccountCommand.Result> Delete([FromUri] RemoveAccountCommand command)
 {
     return(await _commandDispatcher.Execute <RemoveAccountCommand, RemoveAccountCommand.Result>(command));
 }
コード例 #8
0
 public void Handle(RemoveAccountCommand removeCusomerCommand)
 {
 }