Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            IAccountService       service = _Resolver.Get <IAccountService>();
            IAccountNumberService creator = _Resolver.Get <IAccountNumberService>();

            service.OpenAccount("Owner", "First", AccountType.Base, creator);
            service.OpenAccount("Owner", "Second", AccountType.Silver, creator);
            service.OpenAccount("Owner", "Third", AccountType.Gold, creator);
            service.OpenAccount("Owner", "Fourth", AccountType.Base, creator);

            var accounts = service.GetAllAccounts();

            foreach (var t in accounts)
            {
                service.DepositAccount(t, 100);
            }

            foreach (var item in service.GetAllAccounts())
            {
                Console.WriteLine(item);
            }

            foreach (var t in accounts)
            {
                service.WithdrawAccount(t, 10);
            }

            foreach (var item in service.GetAllAccounts())
            {
                Console.WriteLine(item);
            }

            Console.ReadLine();
        }
        public AccountApplicationService(IAggregateRepository<Account> accountRepository, IAccountProjections accountProjections,
            IAccountNumberService accountNumberService, IUnitOfWork unitOfWork)
        {
            this.accountRepository = accountRepository;
            this.accountProjections = accountProjections;
            this.accountNumberService = accountNumberService;
            this.unitOfWork = unitOfWork;

            SubsribeToEvents();
        }
Ejemplo n.º 3
0
        public void OpenAccount(string firstName, string lastName, AccountType accountType, IAccountNumberService accountNumberCreator)
        {
            int id = accountNumberCreator.GenerateNumber(Last);

            _repository.AddAccount(new BankAccountDTO(id, firstName, lastName, 0.0m, 0, accountType.ToString()));
        }
Ejemplo n.º 4
0
 public ClientService(AggregateRepository<Client> clientRepository, IAccountNumberService accountNumberService, IUnitOfWork unitOfWork)
 {
     this.clientRepository = clientRepository;
     this.accountNumberService = accountNumberService;
     this.unitOfWork = unitOfWork;
 }
 public AccountApplicationService(IAggregateRepository<Account> accountRepository, IAccountNumberService accountNumberService, IUnitOfWork unitOfWork)
 {
     this.accountRepository = accountRepository;
     this.accountNumberService = accountNumberService;
     this.unitOfWork = unitOfWork;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractAccountService"/> class.
 /// </summary>
 /// <param name="repository">
 /// Repository which stores bank accounts data.
 /// </param>
 /// <param name="accountNumberService">
 /// Account number service that creates unique account numbers.
 /// </param>
 protected AbstractAccountService(IRepository repository, IAccountNumberService accountNumberService)
 {
     this.AccountNumberService = accountNumberService ?? throw new ArgumentNullException(nameof(accountNumberService));
     this.Repository           = repository ?? throw new ArgumentNullException(nameof(repository));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AccountService"/> class.
 /// </summary>
 /// <param name="repository">
 /// Repository which stores bank accounts data.
 /// </param>
 /// <param name="accountNumberService">
 /// Account number service that creates unique account numbers.
 /// </param>
 public AccountService(IRepository repository, IAccountNumberService accountNumberService)
     : base(repository, accountNumberService)
 {
 }