public OtherCatholicPrayer Find(int id)
        {
            var otherCatholicPrayer = new OtherCatholicPrayer();

            using (var sp = new StoredProcedure("spFindOtherCatholicPrayer"))
            {
                sp.SqlCommand.Parameters.AddWithValue("@othercatholicprayerID", id);

                var reader = sp.SqlCommand.ExecuteReader();

                while (reader.Read())
                {
                    otherCatholicPrayer = _otherCatholicPrayerTransformer.Transform(reader);
                }
            }

            return(otherCatholicPrayer);
        }
Exemple #2
0
        public Models.OtherCatholicPrayer Find(int id)
        {
            var otherCatholicPrayer = new Models.OtherCatholicPrayer();

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

                using (var cmd = new SqlCommand("spFindOtherCatholicPrayer", dbconn))
                {
                    try
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@othercatholicprayerID", id);


                        var reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            otherCatholicPrayer = _otherCatholicPrayerTransformer.Transform(reader);
                        }
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }
            }

            return(otherCatholicPrayer);
        }
Exemple #3
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);
        }