public void UpdateBankAccountCommandFail()
        {
            var cmd = new UpdateBankAccountCommand(_id, Guid.NewGuid(), string.Empty, string.Empty);

            _handler.Handle(cmd);
            Assert.IsFalse(_handler.Valid, _handler.Notifications.FirstOrDefault().Message);
        }
        public Task<bool> Handle(UpdateBankAccountCommand command)
        {
            var entity = _repository.Get(command.Id);
            if (entity == null)
            {
                AddNotification("correntista", "Correntista não localizado");
                return Task.FromResult(false);
            }

            var bankAccount = entity.GetAccount(command.AccountId);
            if (bankAccount == null)
            {
                AddNotification("conta-corrente", "Conta não localizada"); ;
                return Task.FromResult(false);
            }

            bankAccount.Update(
                    new Name(command.BankName),
                    command.Number
                );

            AddNotifications(entity, bankAccount);

            if (Invalid) Task.FromResult(false);

            _repository.Update(entity);
            _uow.Commit();

            return Task.FromResult(true);
        }
        public void UpdateBankAccountCommandOk()
        {
            var cmd = new UpdateBankAccountCommand(_id, _idBankAccount, "Santander", "123456");

            _handler.Handle(cmd);
            Assert.IsTrue(_handler.Valid);
        }
Beispiel #4
0
        public async Task <IActionResult> Update(int id, [FromForm] UpdateBankAccountCommand command)
        {
            if (ModelState.IsValid)
            {
                command.ID = id;
                BankAccount taskReturn = await Mediator.Send(command);

                return(Ok(new BankAccountsResponse(nameof(BankAccount), taskReturn, taskReturn.statusCode, _baseLocalizer, _localizer)));
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }