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;
        }
Beispiel #2
0
        public void TransferMoney(Account to, decimal amount)
        {
            if (!HasBalance(amount))
                throw new NoBalanceException();

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