Server.Models.Comment.updateComment C# (CSharp) Méthode

updateComment() public méthode

public updateComment ( int CommentID, string CommentText ) : string
CommentID int
CommentText string
Résultat string
        public string updateComment(int CommentID, string CommentText)
        {
            try
            {
                using (var ctx = new CommentContext())
                {
                    Comment oldComment = ctx.Comments.Find(CommentID);
                    if (oldComment != null)
                    {
                        oldComment.CommentText = CommentText;
                        ctx.SaveChanges();
                    }
                }
                return "ok";
            }
            catch (Exception)
            {
                return "fail";
            }
        }
    }