public CreateResponse CreateAccount(CreateRequest request)
        {
            CreateResponse response = new CreateResponse();

            try
            {
                // Create new account object
                Account newAccount = new Account(request.Balance);

                // Add our new object to pending for pesistence.
                _accountRepository.Add(newAccount);

                // Persist our changes to database.
                _unitOfWork.Commit();
            }
            catch (Exception)
            {
                response.IsSuccessful = false;
                response.Message = "Unable to create account! If problem persist, please contact system administrator.";
                return response;
            }

            response.IsSuccessful = true;
            response.Message = "Account created.";
            return response;
        }
Esempio n. 2
0
        public void TransferMoney(Account to, decimal amount)
        {
            if (!HasBalance(amount))
                throw new NoBalanceException();

            Withdraw(amount);
            to.Deposit(amount);
        }
Esempio n. 3
0
 public void Update(Account entity)
 {
     _uow.Update(entity, this);
 }
Esempio n. 4
0
 public void Delete(Account entity)
 {
     _uow.Delete(entity, this);
 }
Esempio n. 5
0
 public void Add(Account entity)
 {
     _uow.Add(entity, this);
 }