public static void Main(string[] args) { CustomMapper.Init(); using (Resolver) { IBankAccountService bankAccountService = Resolver.Get <IBankAccountService>(); var newBankAccount = new BankAccount(1, "FirstName", "LastName", 20, 0, false, BankAccountTypes.Standart, 10); Console.WriteLine(bankAccountService.AddAccount(newBankAccount)); newBankAccount = new BankAccount(2, "FirstName2", "LastName2", 22, 3, false, BankAccountTypes.Gold, 20); Console.WriteLine(bankAccountService.AddAccount(newBankAccount)); var bankAccountsList = bankAccountService.GetAllBankAccounts(); bankAccountService.Deposit(30, bankAccountsList.ToList()[0].AccountId); bankAccountService.Withdraw(10, bankAccountsList.ToList()[1].AccountId); } Console.ReadKey(); }
public void CreateAccount(BankAccount account) { if (account == null) { throw new ArgumentNullException(); } account.BonusPoints = 10 * (int)rate; _service.AddAccount(account); }
public BankAccount(string id, decimal ballance, string fName, string sName, decimal bonusPoints, AccountRate rate, IBankAccountService service) : base(id, ballance) { if (!System.Enum.IsDefined(typeof(AccountRate), rate)) { throw new InvalidEnumArgumentException(nameof(rate), (int)rate, typeof(AccountRate)); } FName = fName; SName = sName; BonusPoints = bonusPoints; this.rate = rate; _service = service; service.AddAccount(this); }