public async Task <WalletDTO> ActivateWallet(int walletId) { Wallet wallet = await _unitOfWork.WalletRepository.GetById(walletId); if (wallet == null) { throw new ArgumentException($"Wallet with {walletId} doesn't exist"); } wallet.Activate(); await _unitOfWork.WalletRepository.Update(wallet); await _unitOfWork.SaveChangesAsync(); return(new WalletDTO(wallet)); }
public void DemeterMethod(Wallet w) { // According to Law of Demeter a method M of object O can call: // 1. Methods of Object O itself decimal amount = GetWalletAmount(); // 2. Methods of Object passed as argument bool active = w.IsActivated(); // 3. Methods of object, which is held in instance variable Wallet.Activate(); // 4. Methods of any Object which is created locally in method M Wallet myWallet = new Wallet(); myWallet.Activate(); }