/// <summary> /// Opens the account. /// </summary> /// <param name="id">The identifier.</param> /// <param name="accountHolder">The account holder.</param> /// <param name="typeOfBankScore">The type of bank score.</param> public void OpenAccount(IAccountNumberGenerator id, AccountHolder accountHolder, TypeOfBankScore typeOfBankScore) { var account = fabric.Create(accountHolder, id.GenerateAccountNumbers(), typeOfBankScore); account.Status = Status.Open; repository.Create(account); }
/// <inheritdoc /> public string CreateAccount( AccountType type, IAccountNumberGenerator numberGenerator, string ownerFirstName, string ownerLastName, string ownerEmail, decimal balance = 0m, int bonus = 0) { if (ReferenceEquals(numberGenerator, null)) { throw new ArgumentNullException(nameof(numberGenerator)); } try { string accountNumber = numberGenerator.CreateNumber(_repository.GetAllAccounts().ToBllAccounts()); var account = CreateAccountOfSpecifiedType(type, accountNumber, ownerFirstName, ownerLastName, ownerEmail, balance, bonus); _repository.AddAccount(account.ToDtoAccount()); return(accountNumber); } catch (Exception ex) { throw new BankAccountServiceException("Some error occuried while creating new account.", ex); } }
public void OpenAccount(IAccountNumberGenerator gen, AccountHolder person, AccountType priveledge, AccountStatus status, int sum, int bonus, out string id) { BankAccount bankAccount; id = gen.GenerateAccountNumber(person + " " + priveledge); switch ((int)priveledge) { case 1: { bankAccount = new BaseAccount(int.Parse(id), person, status, priveledge, sum, bonus); break; } case 2: { bankAccount = new GoldAccount(int.Parse(id), person, status, priveledge, sum, bonus); break; } case 3: { bankAccount = new PlatinumAccount(int.Parse(id), person, status, priveledge, sum, bonus); break; } default: { bankAccount = new BaseAccount(int.Parse(id), person, status, priveledge, sum, bonus); break; } } bankAccount.Status = AccountStatus.Active; fakeRepository.Create(bankAccount); }
public PlatinumAccount( AccountHolder holder, IAccountNumberGenerator idGenerator, IMoneyAccuracyCalculator rounder = null) : base(holder, idGenerator, rounder) { }
public BankService(IRepository repository, IAccountNumberGenerator idGenerator) { ValidateOnNull(repository, nameof(repository)); ValidateOnNull(idGenerator, nameof(idGenerator)); this.IdGenerator = idGenerator; this.Repository = repository; }
protected BankAccount(AccountHolder holder, IAccountNumberGenerator idGenerator, IMoneyAccuracyCalculator rounder = null) { ValidateOnNull(holder, nameof(holder)); this.Id = idGenerator.GenerateAccountNumber(); this.rounder = rounder ?? new OneHundredthAccuracy(); this.Holder = holder; }
public AccountHandlers( IUnitOfWork unitOfWork, IAccountRepository accountRepository, IAccountNumberGenerator accountNumberGenerator) : base(unitOfWork) { this.accountRepository = accountRepository; this.accountNumberGenerator = accountNumberGenerator; }
public BaseAccount( IAccountNumberGenerator generator, AccountHolder holder, decimal balance = 0m, int bonusPoints = 0) : base(generator, holder, AccountStatus.Base, balance, bonusPoints) { }
public Account(IAccountNumberGenerator generator, PersonalInfo ownersPersonalInfo, decimal balance, bool isClosed, int benefitPoints) { NumberOfAccount = generator.Generate(); OwnersPersonalInfo = ownersPersonalInfo ?? throw new ArgumentNullException(nameof(ownersPersonalInfo)); Balance = balance; this.isClosed = isClosed; this.benefitPoints = benefitPoints; }
/// <summary> /// Create a new SimpleAccount /// </summary> /// <param name="accountOwner">Owner of the account</param> /// <param name="initialDeposit">Initial deposit</param> /// <param name="accountNoGenerator">Account number generator</param> public SimpleAccountFactory(IAccountNumberGenerator accountNoGenerator) { if (accountNoGenerator == null) { throw new ArgumentNullException(); } _accountNoGenerator = accountNoGenerator; }
/// <summary> /// Return new gold account. /// </summary> /// <param name="numGenerator"> /// Account number generator. /// </param> /// <exception cref="ArgumentNullException"> /// Throws if current account number generator is null. /// </exception>> /// <returns> /// Return new gold account. /// </returns> public override AbstractAccount GetNewAccount(IAccountNumberGenerator numGenerator) { if (ReferenceEquals(numGenerator, null)) { throw new ArgumentNullException(nameof(numGenerator)); } return(new GoldAccount(numGenerator.GenerateNewNumber())); }
public AccountCommandHandler( IDocumentSession session, IAccountNumberGenerator accountNumberGenerator, IEventBus eventBus) { this.session = session; this.accountNumberGenerator = accountNumberGenerator; this.eventBus = eventBus; }
public Account(Guid clientId, IAccountNumberGenerator accountNumberGenerator) { var @event = new NewAccountCreated( Guid.NewGuid(), clientId, accountNumberGenerator.Generate() ); Apply(@event); Enqueue(@event); }
public Account(Guid clientId, IAccountNumberGenerator accountNumberGenerator) { var @event = new NewAccountCreated { AccountId = Guid.NewGuid(), ClientId = clientId, Number = accountNumberGenerator.Generate() }; Apply(@event); Append(@event); }
/// <summary> /// Initializes a new instance of the <see cref="BankAccount"/> class. /// </summary> /// <param name="generator">Generator of ID.</param> /// <param name="holder">Account holder.</param> /// <param name="balance">Account's balance.</param> /// <param name="bonusPoints">Account's bonus points.</param> /// <param name="status">Status of account.</param> protected BankAccount( IAccountNumberGenerator generator, AccountHolder holder, AccountStatus status = AccountStatus.Base, decimal balance = 0m, int bonusPoints = 0) { this.Holder = holder; this.Balance = balance; this.BonusPoints = bonusPoints; this.Status = status; this.Id = generator.GenerateAccountNumber(this); // ?? throw new ArgumentNullException(nameof(generator)); }
/// <summary> /// Provides a default Account constructor /// </summary> /// <param name="accountOwner">Owner of the account</param> /// <param name="initialDeposit">Initial account balance</param> /// <param name="accountNo">Unique account number</param> protected Account(IUser accountOwner, Money initialDeposit, IAccountNumberGenerator accountNoGenerator) { if (accountOwner == null || initialDeposit == null || accountNoGenerator == null) { throw new ArgumentNullException(); } ValidateNewAccount(initialDeposit); AccountOwner = accountOwner; AccountNo = accountNoGenerator.CreateAccountNumber(); Balance = initialDeposit; }
public string GenerateAccountNumber(IAccountNumberGenerator account) { StringBuilder sb = new StringBuilder(10); sb.Append(account.GenerateNumber()); Random rd = new Random(); for (int i = 1; i < sb.Length; i++) { sb.Append(rd.Next(10)); } return(sb.ToString()); }
public SimpleAccount(IUser accountOwner, Money initialDeposit, IAccountNumberGenerator accountNoGenerator) : base(accountOwner, initialDeposit, accountNoGenerator) { if (initialDeposit.Currency != _accountCurrency) { throw new ArgumentException(string.Format("This account supports {0} currency only", _accountCurrency)); } // satisfy only minimum balance criteria. When an account is open we do NOT put a max limit on the initial deposit if (initialDeposit.Amount < _minimumBalanceRequired.Amount) { throw new ArgumentOutOfRangeException("This account has a minimum balance of $100"); } }
static Program() { _resolver = new StandardKernel(); _resolver.ConfigurateResolver(); _numberGenerator = _resolver.Get <IAccountNumberGenerator <int> >(); _accountData = new Account[] { new Account(_numberGenerator) { Owner = new Person { LastName = "Smbd", FirstName = "Smbd", Email = "*****@*****.**", SerialNumber = "12345678FF" }, InvoiceAmount = 100, Bonuses = 0, AccountType = new AccountType { Name = ":)", DepositCost = 100, WithdrawCost = 10 } }, new Account(_numberGenerator) { Owner = new Person { LastName = "Smbd1", FirstName = "Smbd1", Email = "*****@*****.**", SerialNumber = "11045678FF" }, InvoiceAmount = 200, Bonuses = 0, AccountType = new AccountType { Name = ":)", DepositCost = 100, WithdrawCost = 10 } } }; }
/// <summary> /// Constructor for creating new Bank account /// </summary> /// <param name="client">Information about account owner</param> /// <param name="startAmount">Value of star amount</param> public BankAccount(Client client, decimal startAmount, IAccountNumberGenerator accountNumberGenerator) { if (client is null) { throw new ArgumentNullException(nameof(client)); } if (startAmount < 0) { throw new ArgumentException(nameof(startAmount)); } if (accountNumberGenerator is null) { throw new ArgumentNullException(nameof(accountNumberGenerator)); } this.AccNumber = SetAccountNumber(accountNumberGenerator); this.Owner = client; this.amount = startAmount; closed = false; BonusPoints = 0; }
/// <summary> /// Opens the account. /// </summary> /// <param name="generator">The generator.</param> /// <param name="holder">The holder.</param> /// <param name="accountType">Type of the account.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">Null argument was sent</exception> /// <exception cref="System.ArgumentException">No such account type exists</exception> public static string OpenAccount(IAccountNumberGenerator generator, AccountHolder holder, string accountType) { if (generator == null || holder == null || accountType == null) { throw new ArgumentNullException("Null argument was sent"); } BankAccount newAccount; switch (accountType.ToLower()) { case "base": { Repository.Create(newAccount = new BaseAccount(holder, generator)); break; } case "silver": { Repository.Create(newAccount = new SilverAccount(holder, generator)); break; } case "gold": { Repository.Create(newAccount = new GoldAccount(holder, generator)); break; } default: { throw new ArgumentException(nameof(accountType) + " is not defined"); } } return(newAccount.IdNumber); }
public override BankAccount Create(AccountHolder holder, IAccountNumberGenerator idGenerator, IMoneyAccuracyCalculator moneyRounder = null) { return(new BaseAccount(holder, idGenerator, moneyRounder)); }
/// <summary> /// Initializes a new instance of the <see cref="BaseAccount"/> class. /// </summary> /// <param name="AccHolder">The account holder.</param> /// <param name="idGenerator">The identifier generator.</param> public BaseAccount(AccountHolder AccHolder, IAccountNumberGenerator idGenerator) : base(AccHolder, idGenerator) { }
/// <summary> /// Initializes a new instance of the <see cref="BankAccount"/> class. /// </summary> /// <param name="AccHolder">The account holder.</param> /// <param name="idGenerator">The identifier generator.</param> protected BankAccount(AccountHolder AccHolder, IAccountNumberGenerator idGenerator) { Holder = AccHolder; idNumber = idGenerator.Generate(); }
public abstract BankAccount Create( AccountHolder holder, IAccountNumberGenerator idGenerator, IMoneyAccuracyCalculator moneyRounder = null);
/// <summary> /// Return new abstract account. /// </summary> /// <param name="numGenerator"> /// Account number generator. /// </param> /// <returns> /// Return new abstract account. /// </returns> public abstract AbstractAccount GetNewAccount(IAccountNumberGenerator numGenerator);
public CreateAccountHandler(IAccountNumberGenerator accountNumberGenerator, IAccountStore accountStore) { _accountNumberGenerator = accountNumberGenerator; _accountStore = accountStore; }
/// <summary> /// The fabric /// </summary>; /// <summary> /// Initializes a new instance of the <see cref="Service"/> class. /// </summary> /// <param name="repository">The repository.</param> public Service(IRepository <DalAccount> repository, IRepository <DalAccountHolder> repositoryAccountHolders, IAccountNumberGenerator accountNumberGenerator) { this.repositoryAccounts = repository; this.repositoryAccountHolders = repositoryAccountHolders; this.numberGenerator = accountNumberGenerator; }
public Account(IAccountNumberGenerator generator, PersonalInfo ownersPersonalInfo) : this(generator, ownersPersonalInfo, 0, true, 0) { OwnersPersonalInfo = ownersPersonalInfo ?? throw new ArgumentNullException(nameof(ownersPersonalInfo)); }
public CreateNewAccountHandler(IAccountNumberGenerator accountNumberGenerator, ISession session, IEventBus eventBus) { _accountNumberGenerator = accountNumberGenerator; _eventBus = eventBus; _session = session; }
public SilverBankAccount(Client client, decimal startAmount, IAccountNumberGenerator accountNumberGenerator) : base(client, startAmount, accountNumberGenerator) { }
public CreateNewAccountHandler(IDocumentSession session, IAccountNumberGenerator accountNumberGenerator) { _session = session; _accountNumberGenerator = accountNumberGenerator; }
public override BankAccount CreateAccount(IAccountNumberGenerator generator, AccountHolder holder) => new SilverAccount(generator, holder);