/// <summary> /// /// </summary> /// <param name="relationId">Mood</param> /// <param name="relationId2">User Id</param> /// <param name="relationId3"></param> /// <param name="relationId4"></param> /// <returns></returns> public List <BibleVerse> Get(int relationId = 0, int relationId2 = 0, int relationId3 = 0, int relationId4 = 0) { var bibleVerses = new List <BibleVerse>(); var mood = new Mood(); using (var dbconn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString)) { if (dbconn.State == ConnectionState.Open) { dbconn.Close(); } dbconn.Open(); using (var cmd = new SqlCommand("spGetBibleVerse", dbconn)) { try { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@moods", mood.GetValue(relationId)); cmd.Parameters.AddWithValue("@userID", relationId2); var reader = cmd.ExecuteReader(); while (reader.Read()) { var verse = _bibleVerseTransformer.Transform(reader); verse.IsFavorite = Convert.ToBoolean(reader["isFavorite"]); bibleVerses.Add(verse); } } catch (Exception) { // ignored } } } return(bibleVerses); }
/// <summary> /// </summary> /// <param name="relationId">Mood</param> /// <param name="relationId2">User Id</param> /// <param name="relationId3"></param> /// <param name="relationId4"></param> /// <returns></returns> public List <BibleVerse> Get(int relationId = 0, int relationId2 = 0, int relationId3 = 0, int relationId4 = 0) { var bibleVerses = new List <BibleVerse>(); var mood = new Mood(); using (var sp = new StoredProcedure("spGetBibleVerse")) { sp.SqlCommand.Parameters.AddWithValue("@moods", mood.GetValue(relationId)); sp.SqlCommand.Parameters.AddWithValue("@userID", relationId2); var reader = sp.SqlCommand.ExecuteReader(); while (reader.Read()) { var verse = _bibleVerseTransformer.Transform(reader); verse.IsFavorite = Convert.ToBoolean(reader["isFavorite"]); bibleVerses.Add(verse); } } return(bibleVerses); }
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); }