protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3L_SSTfLP_1404 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 ORM_LOG_LogisticsProvider logisticProvider1 = new ORM_LOG_LogisticsProvider(); logisticProvider1.Load(Connection, Transaction, Parameter.LogisticProviderID); ORM_CMN_BPT_AvailableShipmentType.Query queryShipmentTypes = new ORM_CMN_BPT_AvailableShipmentType.Query(); queryShipmentTypes.CMN_BPT_BusinessParticipant_RefID = logisticProvider1.Ext_CMN_BPT_BusinessParticipant_RefID; queryShipmentTypes.LOG_SHP_Shipment_Type_RefID = Parameter.ShipmentTypeID; queryShipmentTypes.Tenant_RefID = securityTicket.TenantID; queryShipmentTypes.IsDeleted = false; var shipmentTypeExists = ORM_CMN_BPT_AvailableShipmentType.Query.Exists(Connection, Transaction, queryShipmentTypes); if (shipmentTypeExists) { if (Parameter.IsPrimaryShipmentType) { ORM_CMN_BPT_AvailableShipmentType.Query queryST = new ORM_CMN_BPT_AvailableShipmentType.Query(); queryST.CMN_BPT_BusinessParticipant_RefID = logisticProvider1.Ext_CMN_BPT_BusinessParticipant_RefID; queryST.IsPrimaryShipmentType = true; queryST.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_AvailableShipmentType.Query querySTvalue = new ORM_CMN_BPT_AvailableShipmentType.Query(); querySTvalue.IsPrimaryShipmentType = false; ORM_CMN_BPT_AvailableShipmentType.Query.Update(Connection, Transaction, queryST, querySTvalue); } var availableShipmentType = ORM_CMN_BPT_AvailableShipmentType.Query.Search(Connection, Transaction, queryShipmentTypes); var availableShipmentTypeID = availableShipmentType.Select(x => x.CMN_BPT_AvailableShipmentTypeID).FirstOrDefault(); ORM_CMN_BPT_AvailableShipmentType shipmentType = new ORM_CMN_BPT_AvailableShipmentType(); shipmentType.Load(Connection, Transaction, availableShipmentTypeID); shipmentType.IsPrimaryShipmentType = Parameter.IsPrimaryShipmentType; shipmentType.Save(Connection, Transaction); returnValue.Result = availableShipmentTypeID; } else { if (Parameter.IsPrimaryShipmentType) { ORM_CMN_BPT_AvailableShipmentType.Query queryST = new ORM_CMN_BPT_AvailableShipmentType.Query(); queryST.CMN_BPT_BusinessParticipant_RefID = logisticProvider1.Ext_CMN_BPT_BusinessParticipant_RefID; queryST.IsPrimaryShipmentType = true; queryST.Tenant_RefID = securityTicket.TenantID; ORM_CMN_BPT_AvailableShipmentType.Query querySTvalue = new ORM_CMN_BPT_AvailableShipmentType.Query(); querySTvalue.IsPrimaryShipmentType = false; ORM_CMN_BPT_AvailableShipmentType.Query.Update(Connection, Transaction, queryST, querySTvalue); } ORM_LOG_LogisticsProvider logisticProvider = new ORM_LOG_LogisticsProvider(); logisticProvider.Load(Connection, Transaction, Parameter.LogisticProviderID); ORM_CMN_BPT_AvailableShipmentType newShipmentType = new ORM_CMN_BPT_AvailableShipmentType(); newShipmentType.CMN_BPT_AvailableShipmentTypeID = Guid.NewGuid(); newShipmentType.CMN_BPT_BusinessParticipant_RefID = logisticProvider.Ext_CMN_BPT_BusinessParticipant_RefID; newShipmentType.LOG_SHP_Shipment_Type_RefID = Parameter.ShipmentTypeID; newShipmentType.IsPrimaryShipmentType = Parameter.IsPrimaryShipmentType; newShipmentType.Tenant_RefID = securityTicket.TenantID; newShipmentType.Save(Connection, Transaction); returnValue.Result = newShipmentType.CMN_BPT_AvailableShipmentTypeID; } return(returnValue); #endregion UserCode }
///<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_L3L_SSTfLP_1404 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(Connection, Transaction, null, Parameter, securityTicket)); }
///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L3L_SSTfLP_1404 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_SaveShipmentTypeforLogisticProvider", ex); } return(functionReturn); }
///<summary> /// Opens the connection/transaction for the given connectionString, and closes them when complete ///<summary> public static FR_Guid Invoke(string ConnectionString, P_L3L_SSTfLP_1404 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(null, null, ConnectionString, Parameter, securityTicket)); }