Exemplo n.º 1
0
        public bool AddSurvey(AdacitySurvey surveyData)
        {
            var result = false;
            if (surveyData != null)
            {
                result = AddSurveyToDB(surveyData);
            }

            return result;
        }
Exemplo n.º 2
0
        private bool AddSurveyToDB(AdacitySurvey surveyData)
        {
            var result = true;
            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = "[adacitySurvey].[SaveSurvey]";
                cmd.Parameters.AddWithValue("@AgeGroup", surveyData.AgeGroup);
                cmd.Parameters.AddWithValue("@Employment", surveyData.Employment);
                cmd.Parameters.AddWithValue("@Option", surveyData.Option);
                cmd.Parameters.AddWithValue("@EntertainmentCategory", surveyData.EntertainmentCategory);

                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception)
                {
                    result = false;
                    throw;
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }

                return result;
            }
        }