Esempio n. 1
0
 public int AddPackage(LoanProduct package)
 {
     if (package.UseLoanCycle)
     {
         SetDefaultValues(package);
     }
     using (var connection = _productManager.GetConnection())
         using (var transaction = connection.BeginTransaction())
         {
             try
             {
                 package.Id = _productManager.Add(package, transaction);
                 _productManager.InsertEntryFees(package.EntryFees, package.Id, transaction);
                 LoanProductInterceptorSave(new Dictionary <string, object>
                 {
                     { "LoanProduct", package },
                     { "SqlTransaction", transaction }
                 });
                 transaction.Commit();
             }
             catch (Exception)
             {
                 transaction.Rollback();
                 throw;
             }
         }
     return(package.Id);
 }
Esempio n. 2
0
 public int InsertLoanCycle(LoanCycle loanCycle)
 {
     if (_productManager.IsLoanCycleNameAlreadyExist(loanCycle.Name))
     {
         throw new OpenCbsPackageSaveException(OpenCbsPackageSaveExceptionEnum.LoanCycleNameAlreadyExists);
     }
     using (SqlConnection conn = _productManager.GetConnection())
         using (SqlTransaction t = conn.BeginTransaction())
         {
             try
             {
                 loanCycle.Id = _productManager.InsertLoanCycle(loanCycle, t);
                 t.Commit();
                 return(loanCycle.Id);
             }
             catch (Exception ex)
             {
                 t.Rollback();
                 throw ex;
             }
         }
 }