protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L2DT_DMDTPfT_1112 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); //Put your code here foreach (var item in Parameter.Charging_levels_to_Delete) { P_L6DTPG_SCL_1016 chargingLevelParameter = new P_L6DTPG_SCL_1016(); chargingLevelParameter.IsDeleted = true; chargingLevelParameter.CMN_BPT_InvestedWorkTime_ChargingLevelID = Guid.Parse(item); cls_Save_Price_Grade_Charging_Level.Invoke(Connection, Transaction, chargingLevelParameter, securityTicket); } return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6DTPG_SCL_1016 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); var item = new ORM_CMN_BPT_InvestedWorkTime_ChargingLevel(); #region Unnecessary if (Parameter.CMN_BPT_InvestedWorkTime_ChargingLevelID != Guid.Empty) { var result = item.Load(Connection, Transaction, Parameter.CMN_BPT_InvestedWorkTime_ChargingLevelID); if (result.Status != FR_Status.Success || item.CMN_BPT_InvestedWorkTime_ChargingLevelID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } if (Parameter.ChargingLevelName != null) { item.ChangingLevel_Name = Parameter.ChargingLevelName; } item.Save(Connection, Transaction); ORM_CMN_SLS_Price.Query priceQuery = new ORM_CMN_SLS_Price.Query(); priceQuery.Tenant_RefID = securityTicket.TenantID; priceQuery.IsDeleted = false; priceQuery.CMN_PRO_Product_RefID = item.CMN_PRO_Product_RefID; List <ORM_CMN_SLS_Price> prices = ORM_CMN_SLS_Price.Query.Search(Connection, Transaction, priceQuery); if (prices != null && prices.Count == 1) { ORM_CMN_SLS_Price price = prices[0]; price.PriceAmount = Parameter.PricePerMinute; price.CMN_Currency_RefID = Parameter.CurrencyID; price.Save(Connection, Transaction); } } else { var structureHeader = new ORM_DOC_Structure_Header(); structureHeader.Label = "document_header_for_product"; structureHeader.Tenant_RefID = securityTicket.TenantID; var structureStatusSave = structureHeader.Save(Connection, Transaction); ORM_CMN_PRO_Product product = new ORM_CMN_PRO_Product(); product.Product_Name = Parameter.ChargingLevelName; product.Product_DocumentationStructure_RefID = structureHeader.DOC_Structure_HeaderID; product.Product_Number = "product_number"; product.Tenant_RefID = securityTicket.TenantID; product.Save(Connection, Transaction); ORM_CMN_BPT_InvestedWorkTime_ChargingLevel charginglevel = new ORM_CMN_BPT_InvestedWorkTime_ChargingLevel(); charginglevel.ChangingLevel_Name = Parameter.ChargingLevelName; charginglevel.CMN_PRO_Product_RefID = product.CMN_PRO_ProductID; charginglevel.Tenant_RefID = securityTicket.TenantID; charginglevel.Save(Connection, Transaction); ORM_CMN_SLS_Price price = new ORM_CMN_SLS_Price(); price.CMN_Currency_RefID = Parameter.CurrencyID; price.CMN_PRO_Product_RefID = product.CMN_PRO_ProductID; price.PriceAmount = Parameter.PricePerMinute; price.Tenant_RefID = securityTicket.TenantID; price.Save(Connection, Transaction); } #endregion return(returnValue); #endregion UserCode }
///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L6DTPG_SCL_1016 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; FR_Guid functionReturn = new FR_Guid(); try { if (cleanupConnection == true) { Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString); Connection.Open(); } if (cleanupTransaction == true) { Transaction = Connection.BeginTransaction(); } functionReturn = Execute(Connection, Transaction, Parameter, securityTicket); #region Cleanup Connection/Transaction //Commit the transaction if (cleanupTransaction == true) { Transaction.Commit(); } //Close the connection if (cleanupConnection == true) { Connection.Close(); } #endregion } catch (Exception ex) { try { if (cleanupTransaction == true && Transaction != null) { Transaction.Rollback(); } } catch { } try { if (cleanupConnection == true && Connection != null) { Connection.Close(); } } catch { } throw new Exception("Exception occured in method cls_Save_Price_Grade_Charging_Level", ex); } return(functionReturn); }
///<summary> /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured ///<summary> public static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, P_L6DTPG_SCL_1016 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(Connection, Transaction, null, Parameter, securityTicket)); }
///<summary> /// Opens the connection/transaction for the given connectionString, and closes them when complete ///<summary> public static FR_Guid Invoke(string ConnectionString, P_L6DTPG_SCL_1016 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(null, null, ConnectionString, Parameter, securityTicket)); }