示例#1
0
        public List <OtherCatholicPrayer> GetFavoriteOtherCatholicPrayer(int userId)
        {
            var otherCatholicPrayers           = new List <OtherCatholicPrayer>();
            var otherCatholicPrayerTransformer = new OtherCatholicPrayerTransformer();

            using (var sp = new StoredProcedure("spGetFavoriteOtherCatholicPrayer"))
            {
                sp.SqlCommand.Parameters.AddWithValue("@userID", userId);

                var reader = sp.SqlCommand.ExecuteReader();

                while (reader.Read())
                {
                    otherCatholicPrayers.Add(otherCatholicPrayerTransformer.Transform(reader));
                }
            }

            return(otherCatholicPrayers);
        }
        public List <Models.OtherCatholicPrayer> GetFavoriteOtherCatholicPrayer(int userId)
        {
            var otherCatholicPrayers           = new List <Models.OtherCatholicPrayer>();
            var otherCatholicPrayerTransformer = new OtherCatholicPrayerTransformer();

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

                using (var cmd = new SqlCommand("spGetFavoriteOtherCatholicPrayer", dbconn))
                {
                    try
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@userID", userId);


                        var reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            otherCatholicPrayers.Add(otherCatholicPrayerTransformer.Transform(reader));
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }
            }

            return(otherCatholicPrayers);
        }
 public OtherCatholicPrayerService()
 {
     _otherCatholicPrayerTransformer = new OtherCatholicPrayerTransformer();
 }