public PostModel Create(Post post) { return new PostModel { Url= _urlHelper.Link("PostApi", new {PostId= post.Id}), Body = post.Body, Score= post.Score }; }
public void Add(Post post) { post.Id = GetNewId(); using (var connection = new MySqlConnection( "server= localhost;database=stackoverflow;uid=root;pwd=princess786")) { connection.Open(); var cmd = new MySqlCommand( "insert into post(id,body) values(@id, @body)", connection); cmd.Parameters.AddWithValue("@id", post.Id); cmd.Parameters.AddWithValue("@body", post.Body); cmd.ExecuteNonQuery(); } }