private Chilindo.BAL.BALModels.ProcessedResponse ProcessResponse(int accNo, decimal bal, string curr, bool status, string err)
 {
     Chilindo.BAL.BALModels.ProcessedResponse result = new Chilindo.BAL.BALModels.ProcessedResponse();
     result.AccountNumber = accNo;
     result.Balance       = bal;
     result.Currency      = curr;
     result.Sucessful     = status;
     result.Message       = err;
     return(result);
 }
        public Chilindo.BAL.BALModels.ProcessedResponse Withdraw(int accountNumber, decimal amount, string apiCurrency, string currency)
        {
            Chilindo.BAL.BALModels.ProcessedResponse objResponse = null;
            decimal newBalance = 0;

            try
            {
                var tempCurrentBalance = _customerAccountInfo.GetAccountBalance(accountNumber);
                var currentCoversion   = _CurrencyConversion.GetCurrency(apiCurrency, currency);
                newBalance = tempCurrentBalance - (currentCoversion * amount);
                if (newBalance > 0)
                {
                    // Update the Balance
                    Chilindo.DAL.Models.Account tempAccount = new Chilindo.DAL.Models.Account();
                    tempAccount.AccountNumber = accountNumber;
                    tempAccount.Balance       = newBalance;
                    tempAccount.LastUpdatedOn = DateTime.UtcNow;
                    _customerAccountInfo.UpdateBalance(tempAccount);

                    // Update the AccountHistory Table
                    Chilindo.DAL.Models.AccountHistory tempAccountHistory = new Chilindo.DAL.Models.AccountHistory();
                    tempAccountHistory.AccountNumber   = accountNumber;
                    tempAccountHistory.Amount          = amount;
                    tempAccountHistory.Currency        = currency;
                    tempAccountHistory.TransactionType = "Withdraw";
                    tempAccountHistory.LastUpdateOn    = DateTime.UtcNow;
                    _customerAccountInfo.InsertAccountHistory(tempAccountHistory);
                    _customerAccountInfo.Save();
                    objResponse = ProcessResponse(accountNumber, newBalance, currency, true, "Processed Succcessful");
                }
                else
                {
                    objResponse = ProcessResponse(accountNumber, newBalance, currency, false, "Insufficient Money in your account");
                }
            }
            catch (Exception ex)
            {
                objResponse = ProcessResponse(accountNumber, newBalance, currency, false, ex.Message);
            }
            return(objResponse);
        }