Example #1
0
        /// <summary>
        /// Create a new post
        /// </summary>
        /// <param name="obj">post data</param>
        /// <returns>Return a post object</returns>
        public Post Insert(Post obj)
        {
            var originAccount      = _checkingAccountRepository.SelectByNumber(obj.OriginAccountNumber);
            var destinationAccount = _checkingAccountRepository.SelectByNumber(obj.DestinationAccountNumber);

            obj.IDOriginAccount      = originAccount.Id;
            obj.IDDestinationAccount = destinationAccount.Id;
            _repository.Insert(obj);
            return(obj);
        }
Example #2
0
        /// <summary>
        /// Select a Checking Account by Number
        /// </summary>
        /// <param name="number">Account Number</param>
        /// <returns></returns>
        public CheckingAccount SelectByNumber(string number)
        {
            if (string.IsNullOrEmpty(number))
            {
                throw new ArgumentException("The number can not be empty.");
            }

            var checkingAccount = _repository.SelectByNumber(number);

            if (checkingAccount != null)
            {
                checkingAccount.Credits = _postRepo.SumCredit(checkingAccount.Id);
                checkingAccount.Debits  = _postRepo.SumDebit(checkingAccount.Id);
            }
            return(checkingAccount);
        }