public Task <bool> Handle(RegisterNewExpenseCommand command) { var owner = _accountantRepository.Get(command.Owner); if (owner == null) { AddNotification("correntista", "Correntista não localizado"); return(Task.FromResult(false)); } var bankAccount = owner.GetAccount(command.Account); if (bankAccount == null) { AddNotification("conta-corrente", "Conta corrente não localizada"); return(Task.FromResult(false)); } var entity = new Expense( Guid.NewGuid(), bankAccount, new Description(command.Description), _favoredRepository.Get(command.Favored), new Money(command.Value) ); AddNotifications(entity); if (Invalid) { return(Task.FromResult(false)); } _expenseRepository.Create(entity); _uow.Commit(); return(Task.FromResult(true)); }
public Task<bool> Handle(UpdateAccountantCommand command) { var entity = _repository.Get(command.Id); if (entity == null) { AddNotification("correntista", "Correntista não localizado"); return Task.FromResult(true); } entity.Update(new Name(command.Name)); AddNotifications(entity); if (Invalid) return Task.FromResult(false); _repository.Update(entity); _uow.Commit(); return Task.FromResult(true); }