protected static FR_Int Execute(DbConnection Connection, DbTransaction Transaction, P_L5ST_UDSfD_1010 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Int();

            var statistics = ORM_HEC_DIA_STA_Diagnosis_UsageStatistic.Query.Search(Connection, Transaction, new ORM_HEC_DIA_STA_Diagnosis_UsageStatistic.Query()
            {
                Tenant_RefID = securityTicket.TenantID,
                IsDeleted    = false,
                IfStatistics_ForDoctor_Doctor_RefID = Parameter.DoctorID,
                IsStatistics_ForDoctor   = true,
                PotentialDiagnosis_RefID = Parameter.PotentialDiagnosisID
            }).SingleOrDefault();

            if (statistics == null)
            {
                if (Parameter.IsCorrection)
                {
                    return(returnValue);
                }

                statistics = new ORM_HEC_DIA_STA_Diagnosis_UsageStatistic()
                {
                    HEC_DIA_STA_DiagnosisUsageStatisticsID = Guid.NewGuid(),
                    Tenant_RefID           = securityTicket.TenantID,
                    IsStatistics_ForDoctor = true,
                    IfStatistics_ForDoctor_Doctor_RefID = Parameter.DoctorID,
                    PotentialDiagnosis_RefID            = Parameter.PotentialDiagnosisID,
                    StatisticsPeriod_From  = DateTime.Now,
                    IsLatestStatisticsData = true
                };
            }

            if (Parameter.IsCorrection)
            {
                statistics.NumberOfOccurences -= 1;
            }
            else
            {
                statistics.NumberOfOccurences += 1;
            }
            statistics.StatisticsPeriod_Through = DateTime.Now;
            statistics.Modification_Timestamp   = DateTime.Now;
            statistics.Save(Connection, Transaction);

            returnValue.Result = statistics.NumberOfOccurences;

            return(returnValue);

            #endregion UserCode
        }
 ///<summary>
 /// Ivokes the method with the given Connection, leaving it open if no exceptions occured
 ///<summary>
 public static FR_Int Invoke(DbConnection Connection, P_L5ST_UDSfD_1010 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, null, null, Parameter, securityTicket));
 }
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Int Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5ST_UDSfD_1010 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_Int functionReturn = new FR_Int();

            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_UpdateDiagnosisStatistics_for_Doctor", ex);
            }
            return(functionReturn);
        }