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

deleteComment() public méthode

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