Esempio n. 1
0
 /// <summary>
 /// The method retrieves payment method by id
 /// </summary>
 /// <param name="paymentMethodId">Id of a payment method</param>
 /// <returns>Returns an instant of the PaymentMethod</returns>
 public PaymentMethod GetPaymentMethodById(int paymentMethodId)
 {
     return(_paymentMethodManager.SelectPaymentMethodById(paymentMethodId));
 }
        private ContractAccountingRule SelectContractAccountingRule(int pId)
        {
            const string sqlText = @"SELECT AccountingRules.id,
                                            AccountingRules.debit_account_number_id, 
                                            AccountingRules.credit_account_number_id,
                                            AccountingRules.booking_direction,
                                            AccountingRules.event_type,
                                            AccountingRules.event_attribute_id,
                                            AccountingRules.[order],
                                            AccountingRules.[description] AS rule_description,
                                            EventAttributes.name AS attribute_name,
                                            EventTypes.description AS event_description,
                                            ContractAccountingRules.product_type, 
                                            ContractAccountingRules.loan_product_id, 
                                            ContractAccountingRules.savings_product_id, 
                                            ContractAccountingRules.client_type, 
                                            ContractAccountingRules.activity_id,
                                            ContractAccountingRules.currency_id
                                    FROM AccountingRules
                                    INNER JOIN EventAttributes ON EventAttributes.id = AccountingRules.event_attribute_id
                                    INNER JOIN EventTypes ON AccountingRules.event_type = EventTypes.event_type
                                    LEFT JOIN ContractAccountingRules ON AccountingRules.id = ContractAccountingRules.id                                    
                                    WHERE AccountingRules.id = @id";

            ContractAccountingRule rule;

            using (SqlConnection conn = GetConnection())
            {
                using (OpenCbsCommand select = new OpenCbsCommand(sqlText, conn))
                {
                    select.AddParam("@id", pId);

                    using (OpenCbsReader reader = select.ExecuteReader())
                    {
                        if (reader.Empty)
                        {
                            return(null);
                        }

                        reader.Read();
                        rule = GetContractAccountingRule(reader);
                    }
                }
            }

            if (rule.LoanProduct != null)
            {
                rule.LoanProduct = _loanProductManager.Select(rule.LoanProduct.Id);
            }

            if (rule.Currency != null)
            {
                rule.Currency = _currencyManager.SelectCurrencyById(rule.Currency.Id);
            }
            if (rule.Currency == null)
            {
                rule.Currency = null;
            }


            if (rule.SavingProduct != null)
            {
                rule.SavingProduct = _savingProductManager.SelectSavingProduct(rule.SavingProduct.Id);
            }

            if (rule.EconomicActivity != null)
            {
                rule.EconomicActivity = _economicActivityManager.SelectEconomicActivity(rule.EconomicActivity.Id);
            }

            if (rule.PaymentMethod.Id != 0)
            {
                rule.PaymentMethod = _paymentMethodManager.SelectPaymentMethodById(rule.PaymentMethod.Id);
            }

            return(rule);
        }