public void ValidateWalletAccessRight_NullWalletAccessRight_ThrowException( WalletAccessRight walletAccessRight) { var walletAccessRightService = new WalletAccessRightService(ProvidersFactory.GetNewWalletsProviders(), new CommonService()); walletAccessRightService.Validate(walletAccessRight); }
/// <summary> /// Validates wallet access rights /// </summary> /// <param name="walletAccessRight">Wallet access right to validate</param> /// <returns>True if wallet access right is valid, false otherwise</returns> public void Validate(WalletAccessRight walletAccessRight) { if (walletAccessRight == null) throw new ArgumentNullException(nameof(walletAccessRight)); this._validator.ValidateAndThrowCustomException(walletAccessRight); }
public void ValidateWalletAccessRight_NullWallet_ThrowException() { var walletAccessRight = new WalletAccessRight { Wallet = null, Permission = PermissionEnum.Read, UserProfile = new UserProfile() }; var walletAccessRightService = new WalletAccessRightService(ProvidersFactory.GetNewWalletsProviders(), new CommonService()); walletAccessRightService.Validate(walletAccessRight); }
public void ValidateWalletAccessRight_ValidWallet_ReturnTrue() { var walletAccessRight = new WalletAccessRight { Wallet = new Wallet { Name = "Default Wallet", Currency = new Currency { Name = "Default currency", Code = "DC", Symbol = "C" } }, Permission = PermissionEnum.Read, UserProfile = new UserProfile() }; var walletAccessRightService = new WalletAccessRightService(ProvidersFactory.GetNewWalletsProviders(), new CommonService()); Assert.DoesNotThrow(() => walletAccessRightService.Validate(walletAccessRight)); }
/// <summary> /// Creates new wallet access right /// </summary> /// <param name="walletId">id of wallet</param> /// <param name="userId">id of user</param> /// <param name="permission">string of permission</param> /// <returns></returns> public async Task CreateWalletAccessRight(Guid walletId, Guid userId, string permission) { var walletAccessRight = new WalletAccessRight { Guid = Guid.NewGuid(), Wallet = await this.GetWalletById(walletId), UserProfile = await this.GetUserProfileById(userId), Permission = this._commonService.ConvertPermissionStringToEnum(permission) }; this.Validate(walletAccessRight); await this._wallets.AddOrUpdateAsync(walletAccessRight); }
private WalletAccessRightEditModel ConvertEntityToEditModel(WalletAccessRight entity) { var model = Mapper.Map<WalletAccessRightEditModel>(entity); model.Permissions = this.GetPermissions(); return model; }