/// <summary> /// Updates record for the dbo.Feedback table. /// SQL+ Routine: dbo.FeedbackUpdate - Authored by Alan Hyneman /// </summary> public FeedbackUpdateOutput FeedbackUpdate(IFeedbackUpdateInput input, bool bypassValidation = false) { if (!bypassValidation) { if (!input.IsValid()) { throw new ArgumentException("FeedbackUpdateInput fails validation - use the FeedbackUpdateInput.IsValid() method prior to passing the input argument to the FeedbackUpdate method.", "input"); } } FeedbackUpdateOutput output = new FeedbackUpdateOutput(); if (sqlConnection != null) { using (SqlCommand cmd = GetFeedbackUpdateCommand(sqlConnection, input)) { cmd.Transaction = sqlTransaction; FeedbackUpdateCommand(cmd, output); } return(output); } for (int idx = 0; idx <= retryOptions.RetryIntervals.Count; idx++) { if (idx > 0) { System.Threading.Thread.Sleep(retryOptions.RetryIntervals[idx - 1]); } try { using (SqlConnection cnn = new SqlConnection(connectionString)) using (SqlCommand cmd = GetFeedbackUpdateCommand(cnn, input)) { cnn.Open(); FeedbackUpdateCommand(cmd, output); cnn.Close(); } break; } catch (SqlException sqlException) { bool throwException = true; if (retryOptions.TransientErrorNumbers.Contains(sqlException.Number)) { throwException = (idx == retryOptions.RetryIntervals.Count); if (retryOptions.Logger != null) { retryOptions.Logger.Log(sqlException); } } if (throwException) { throw; } } } return(output); }
/// <summary> /// Builds the command object for FeedbackUpdate method. /// </summary> /// <param name="cnn">The connection that will execute the procedure.</param> /// <param name="input">FeedbackUpdateInput instance for loading parameter values.</param> /// <returns>SqlCommand ready for execution.</returns> private SqlCommand GetFeedbackUpdateCommand(SqlConnection cnn, IFeedbackUpdateInput input) { SqlCommand result = new SqlCommand() { CommandType = CommandType.StoredProcedure, CommandText = "[dbo].[FeedbackUpdate]", Connection = cnn }; result.Parameters.Add(new SqlParameter() { ParameterName = "@FeedbackId", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.Int, Scale = 0, Precision = 10, Value = input.FeedbackId }); result.Parameters.Add(new SqlParameter() { ParameterName = "@LastName", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Size = 32, Value = input.LastName }); result.Parameters.Add(new SqlParameter() { ParameterName = "@FirstName", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Size = 32, Value = input.FirstName }); result.Parameters.Add(new SqlParameter() { ParameterName = "@Email", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.VarChar, Size = 64, Value = input.Email }); result.Parameters.Add(new SqlParameter() { ParameterName = "@Subject", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Size = 32, Value = input.Subject }); result.Parameters.Add(new SqlParameter() { ParameterName = "@Message", Direction = ParameterDirection.Input, SqlDbType = SqlDbType.NVarChar, Size = 1024, Value = input.Message }); result.Parameters.Add(new SqlParameter() { ParameterName = "@ReturnValue", Direction = ParameterDirection.ReturnValue, SqlDbType = SqlDbType.Int, Scale = 0, Precision = 10, Value = DBNull.Value }); return(result); }