public async Task EditAsync(BankAccountEditModel model) { var bankAccount = await _bankAccountRepository.GetAsync(model.Id); BankAccountFactory.Create(model, bankAccount, _userId); _bankAccountRepository.Edit(bankAccount); await _unitOfWork.SaveChangesAsync(); }
public void OpenAccount(AccountHolder holder, BankAccountFactory factory) { ValidateOnNull(holder, nameof(holder)); ValidateOnNull(factory, nameof(factory)); BankAccount account = factory.Create(holder, this.IdGenerator); holder.AddAccount(account); this.Repository.Save(account); }
public static List <AbstractBankAccount> ToAbstractBankAccountList(List <DAL.Interface.DTO.BankAccount> accounts) { return(accounts.Select((m) => { var result = BankAccountFactory.Create(Mapper.Map <BankAccountType>(m.AccountType), m.AccountNumber); result.Owner = Mapper.Map <AccountOwner>(m.Owner); result.Balance = m.Balance; result.BonusPoints = m.BonusPoints; return result; }).ToList()); }
public async Task AddAsync(BankAccountAddModel model) { var result = BankAccountFactory.Create(model, _userId); await _bankAccountRepository.AddAsync(result); if (model.COA_AccountTypeId == 1 || model.COA_AccountTypeId == 2 || model.COA_AccountTypeId == 6 || model.COA_AccountTypeId == 7) { Reconciliation reconciliation = new Reconciliation(); ReconciliationFactory.Create(result.Id, reconciliation); await _reconciliationRepository.AddAsync(reconciliation); } await _unitOfWork.SaveChangesAsync(); }
private BankAccount CreateAccount() { var factory = new BankAccountFactory(); Console.Write("The holder name : "); string name = Console.ReadLine(); Console.WriteLine("Type of the bank account :"); string inputtype = Console.ReadLine(); _id = new AccountIdGenerator().GenerateId(_id); Enum.TryParse(inputtype, true, out BankAccountTypes type); string state = "Open"; Enum.TryParse(state, true, out Status status); BankAccount account = factory.Create(_id.ToString(), name, 0, 0, status, type); return(account); }
public BankAccountRepository() { Accounts = new List <BankAccount>(); RepositoryFileName = Settings.Default.BinaryRepositoryFileName; if (!File.Exists(RepositoryFileName)) { return; } Stream stream = File.OpenRead(RepositoryFileName); using (var reader = new BinaryReader(stream)) { int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { string accountNumber = reader.ReadString(); string ownerFirstName = reader.ReadString(); string ownerLastName = reader.ReadString(); decimal balance = reader.ReadDecimal(); decimal bonusPoints = reader.ReadDecimal(); BankAccountStatus status = (BankAccountStatus)reader.ReadInt32(); BankAccountType type = (BankAccountType)reader.ReadInt32(); var owner = new AccountOwner() { FirstName = ownerFirstName, LastName = ownerLastName }; Accounts.Add(InitializeFields(BankAccountFactory.Create(type, accountNumber), owner, balance, bonusPoints)); } } }
public async Task AddAsync(BankAccountAddModel model) { await _bankAccountRepository.AddAsync(BankAccountFactory.Create(model, _userId)); await _unitOfWork.SaveChangesAsync(); }