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

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