public List <BibleVerse> GetFavoriteBibleVerses(int userId) { var verses = new List <BibleVerse>(); var bibleVerseTransformer = new BibleVerseTransformer(); using (var sp = new StoredProcedure("spGetFavoriteBibleVerse")) { sp.SqlCommand.Parameters.AddWithValue("@userID", userId); var reader = sp.SqlCommand.ExecuteReader(); while (reader.Read()) { verses.Add(bibleVerseTransformer.Transform(reader)); } } return(verses); }
public static BibleVerse getVerse(DateTime date) { var bibleVerseTransformer = new BibleVerseTransformer(); var verse = new BibleVerse(); using (var dbconn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString)) { if (dbconn.State == ConnectionState.Open) { dbconn.Close(); } dbconn.Open(); using (var cmd = new SqlCommand("spGetDailyBibleVerse", dbconn)) { try { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@dateofVerse", date.ToString("MM/dd/yyyy")); var _reader = cmd.ExecuteReader(); while (_reader.Read()) { verse = bibleVerseTransformer.Transform(_reader); } } catch (Exception ex) { throw new Exception(ex.Message); } finally { dbconn.Close(); dbconn.Dispose(); } } return(verse); } }
public List <BibleVerse> GetFavoriteBibleVerses(int userId) { var verses = new List <BibleVerse>(); var bibleVerseTransformer = new BibleVerseTransformer(); using (var dbconn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString)) { if (dbconn.State == ConnectionState.Open) { dbconn.Close(); } dbconn.Open(); using (var cmd = new SqlCommand("spGetFavoriteBibleVerse", dbconn)) { try { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@userID", userId); var reader = cmd.ExecuteReader(); while (reader.Read()) { verses.Add(bibleVerseTransformer.Transform(reader)); } } catch (Exception) { // ignored } } } return(verses); }
public BibleVerseService() { _bibleVerseTransformer = new BibleVerseTransformer(); }