Ejemplo n.º 1
0
        public void Add(Comment c)
        {
            SqlConnection con = CreateConnection();

            try
            {
                con.Open();
                SqlCommand cmd = con.CreateCommand();
                cmd.CommandText = "AddComment";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@recipeID", c.RecipeId);
                cmd.Parameters.AddWithValue("@userID", c.UserId);
                cmd.Parameters.AddWithValue("@comment", c.Content);

                cmd.ExecuteNonQuery();

            }
            catch (SqlException ex)
            {
                throw /*ex*/;
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
 public void AddComment()
 {
     SqlCommentManager scm = new SqlCommentManager();
     Comment c = new Comment();
     c.UserId = 1;
     c.Content = "This is good!";
     scm.Add(c);
 }
Ejemplo n.º 3
0
 public Comment MapDbResultToComment(SqlDataReader res)
 {
     res.Read();
     Comment c = new Comment();
     c.Content = res["content"].ToString();
     c.Username = res["username"].ToString();
     return c;
 }
Ejemplo n.º 4
0
        private Comment MapResultFromDatabaseToCommentObject(SqlDataReader res)
        {
            Comment c = new Comment();
            c.Id = (int)res["id"];
            c.UserId = (int)res["userId"];
            c.Content = res["content"].ToString();

            return c;
        }