/// <summary> /// change categories accessibility for wallet. /// </summary> /// <param name="wallet"></param> /// <param name="category">category to change</param> public void SwitchCategoryPermission(Wallet.Wallet wallet, Category category) { if (!Wallets.Contains(wallet)) { throw new UserException("can not switch categories if you are not owner"); } if (!Categories.Contains(category)) { throw new UserException("user hasn't this category"); } if (wallet is null) { throw new UserException("user hasn't this wallet"); } if (wallet.RestrictedCategories.Contains(category)) { wallet.RestrictedCategories.Remove(category); } else { wallet.RestrictedCategories.Add(category); } }
/// <summary> /// share wallet with another user /// </summary> /// <param name="toShare"></param> /// <param name="user">user to share wallet with</param> public void ShareWalletWithUser(Wallet.Wallet toShare, User user) { if (!Wallets.Contains(toShare)) { throw new UserException("can not share wallet if you are not owner"); } if (user == this) { throw new UserException("can not share wallet with owner"); } if (toShare is null) { throw new UserException("user hasn't this wallet"); } if (user.WalletsShared.Contains(toShare)) { throw new UserException("wallet has been already shared with this user"); } user.WalletsShared.Add(toShare); }