// *** Update Post *** public bool UpdateItem(PostsViewModels iPost) { connection(); string query = "UPDATE Posts SET Title = '" + iPost.Title + "', CreationDate = '" + iPost.CreationDate + "', BodyText = " + iPost.BodyText + "', MediaUrl = " + iPost.MediaUrl + " WHERE Id = " + iPost.Id; SqlCommand cmd = new SqlCommand(query, con); con.Open(); int i = cmd.ExecuteNonQuery(); con.Close(); if (i >= 1) { return(true); } else { return(false); } }
// *** Insert Post *** public bool PostItem(PostsViewModels iPost) { connection(); string query = "INSERT INTO Posts VALUES('" + iPost.CreationDate + "','" + iPost.Title + "','" + iPost.BodyText + "'," + iPost.MediaUrl + ")"; SqlCommand cmd = new SqlCommand(query, con); con.Open(); int i = cmd.ExecuteNonQuery(); con.Close(); if (i >= 1) { return(true); } else { return(false); } }