public updatePost ( int PostID, string PostTitle, string PostText ) : string | ||
PostID | int | |
PostTitle | string | |
PostText | string | |
return | string |
public string updatePost(int PostID, string PostTitle, string PostText)
{
try
{
using (var ctx = new PostContext())
{
Post oldPost = ctx.Posts.Find(PostID);
if (oldPost != null)
{
oldPost.PostTitle = PostTitle;
oldPost.PostText = PostText;
ctx.SaveChanges();
}
}
return "ok";
}
catch (Exception)
{
return "fail";
}
}