public TransferViewModel GetAccountById(Guid aggregateId)
        {
            using (var ctx = new BankAccountDbContext())
            {
                var model = ctx.AccountSet.SingleOrDefault(a => a.AggregateId == aggregateId);
                if (model == null)
                {
                    throw new ArgumentNullException("account");
                }

                return new TransferViewModel
                {
                    AggregateId         = model.AggregateId,
                    CustomerId          = model.CustomerAggregateId,
                    Version             = model.Version
                };
            }
        }
 public IEnumerable<AccountViewModel> GetAccountsByCustomerId(Guid customerId)
 {
     using (var ctx = new BankAccountDbContext())
     {
         var model = ctx.AccountSet.Where(a => a.CustomerAggregateId == customerId);
         var list = new List<AccountViewModel>();
         foreach (var a in model)
         {
             list.Add(
                 new AccountViewModel
                 {
                     Currency        = a.Currency,
                     CustomerId      = a.CustomerAggregateId,
                     AggregateId     = a.AggregateId,
                     AccountState    = a.AccountState
                 });
         }
         return list;
     }
 }
        public IEnumerable<BankAccountViewModel> GetCustomers()
        {
            List<Guid> aggregates;

            using (var ctx = new BankAccountDbContext())
            {
                aggregates = ctx.CustomerSet.Select(c => c.AggregateId).ToList();
            }

            return aggregates
                .Select(this.RehydrateDomainModel)
                .Select(customer =>
                    new BankAccountViewModel
                        {
                            FirstName       = customer.Person.FirstName,
                            LastName        = customer.Person.LastName,
                            Id              = customer.Id
                        })
                .ToList();
        }