/// <summary>
        /// Updates the Control record
        /// </summary>
        /// <param name="entity">The entity.</param>
        public void Update(PatControl entity)
        {
            var patControl = entity;

            Debug.Assert(patControl != null, "control != null");

            using (var connection = new SqlConnection(DbConnection))
            {
                using (var command = new SqlCommand("PaControlUpdate", connection))
                {
                    var sqlParams = new List <SqlParameter>();

                    SqlHelper.AddReturnPara("@return_value", sqlParams);

                    if (patControl.ControlId > 0)
                    {
                        SqlHelper.AddIntPara(patControl.ControlId, "@Id", sqlParams);
                    }

                    SqlHelper.AddIntPara(patControl.ProjectCount, "@ProjectCount", sqlParams);
                    SqlHelper.AddIntPara(patControl.SampleCount, "@SampleCount", sqlParams);
                    SqlHelper.AddIntPara(patControl.ReviewCount, "@ReviewCount", sqlParams);

                    SqlHelper.AddDecimalPara(patControl.ProjectCompletion, 3, "@ProjectCompletion", sqlParams);
                    SqlHelper.AddDecimalPara(patControl.TotalComplianceIndicator, 3, "@TotalComplianceIndicator", sqlParams);

                    SqlHelper.AddBitPara(patControl.SystemAvailable, "@SystemAvailable", sqlParams);

                    if (patControl.LastBatchRun != new DateTime(1, 1, 1))
                    {
                        SqlHelper.AddDatePara(patControl.LastBatchRun, "@LastBatchRun", sqlParams);
                    }
                    if (patControl.LastComplianceRun != new DateTime(1, 1, 1))
                    {
                        SqlHelper.AddDatePara(patControl.LastComplianceRun, "@LastComplianceRun", sqlParams);
                    }

                    SqlHelper.AddVarcharPara(patControl.UpdatedBy, "@UpdatedBy", sqlParams);

                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(sqlParams.ToArray());

                    connection.Open();

                    command.ExecuteNonQuery();
                }
            }
        }
        /// <summary>
        /// Updates the Compliance indicator.
        /// </summary>
        /// <param name="entity">The CI data.</param>
        public void Update(ComplianceIndicator entity)
        {
            var complianceIndicator = entity;

            Debug.Assert(complianceIndicator != null, "complianceIndicator != null");

            using (var connection = new SqlConnection(DbConnection))
            {
                using (var command = new SqlCommand("PaComplianceIndicatorUpdate", connection))
                {
                    var sqlParams = new List <SqlParameter>();

                    var paramReturnValue = new SqlParameter("@return_value", SqlDbType.Int)
                    {
                        Direction = ParameterDirection.ReturnValue
                    };
                    sqlParams.Add(paramReturnValue);

                    SqlHelper.AddIntPara(complianceIndicator.ComplianceIndicatorId, "@Id", sqlParams);

                    SqlHelper.AddVarcharPara(complianceIndicator.Programme, "@Programme", sqlParams);
                    SqlHelper.AddVarcharPara(complianceIndicator.SubjectTypeCode, "@SubjectTypeCode", sqlParams);
                    SqlHelper.AddVarcharPara(complianceIndicator.Subject, "@Subject", sqlParams);
                    SqlHelper.AddVarcharPara(complianceIndicator.EsaCode, "@EsaCode", sqlParams);
                    SqlHelper.AddVarcharPara(complianceIndicator.Quarter, "@Quarter", sqlParams);

                    SqlHelper.AddDecimalPara(complianceIndicator.Value, 3, "@ComplianceIndicator", sqlParams);

                    SqlHelper.AddVarcharPara(complianceIndicator.UpdatedBy, "@UpdatedBy", sqlParams);

                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(sqlParams.ToArray());
                    connection.Open();
                    command.ExecuteNonQuery();
                }
            }
        }