Server.Models.Post.updatePost C# (CSharp) Méthode

updatePost() public méthode

public updatePost ( int PostID, string PostTitle, string PostText ) : string
PostID int
PostTitle string
PostText string
Résultat 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";
            }
        }