Server.Models.Post.updatePost C# (CSharp) 메소드

updatePost() 공개 메소드

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