public AnnotationModel Create(Annotation annotation) { return new AnnotationModel { Url = _urlHelper.Link("AnnotationApi", new { PostId = annotation.PostId }), Body = annotation.Body, Date = annotation.Date }; }
public void Update(Annotation annotation) { using (var connection = new MySqlConnection( "server= localhost;database=stackoverflow;uid=root;pwd=princess786")) { connection.Open(); var cmd = new MySqlCommand( "update annotation set body=@body where postID=@postID", connection); cmd.Parameters.AddWithValue("@postID", annotation.PostId); cmd.Parameters.AddWithValue("@body", annotation.Body); cmd.ExecuteNonQuery(); } }
public void Add(Annotation annotation) { annotation.PostId = GetNewId(); using (var connection = new MySqlConnection( "server= localhost;database=stackoverflow;uid=root;pwd=princess786")) { connection.Open(); var cmd = new MySqlCommand( "insert into annotation(body) values(@body)", connection); //cmd.Parameters.AddWithValue("@postID", annotation.PostId); cmd.Parameters.AddWithValue("@body", annotation.Body); cmd.ExecuteNonQuery(); } }