public static ReligiousQuote GetQuote(DateTime date)
        {
            var religiousTransformer = new ReligiousQuoteTransformer();
            var quote = new ReligiousQuote();

            using (var dbconn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString))
            {
                if (dbconn.State == ConnectionState.Open)
                {
                    dbconn.Close();
                }
                dbconn.Open();

                using (var cmd = new SqlCommand("spGetDailyReligiousQuote", dbconn))
                {
                    try
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@dateofQuote", date.ToString("MM/dd/yyyy"));

                        var reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            quote = religiousTransformer.Transform(reader);
                        }
                    }
                    catch (Exception)
                    {
                        // Ignored
                    }
                }
                return(quote);
            }
        }
Esempio n. 2
0
 public ReligiousQuoteItem(ReligiousQuote religiousQuote)
 {
     ReligiousQuote = religiousQuote;
 }