ReviewR.Web.Services.CommentService.DeleteComment C# (CSharp) Method

DeleteComment() public method

public DeleteComment ( int id, int userId ) : DatabaseActionOutcome
id int
userId int
return DatabaseActionOutcome
        public virtual DatabaseActionOutcome DeleteComment(int id, int userId)
        {
            Requires.InRange(id >= 0, "id");
            Requires.InRange(userId >= 0, "userId");

            Comment cmt = Data.Comments.Where(c => c.Id == id).FirstOrDefault();
            if (cmt == null)
            {
                return DatabaseActionOutcome.ObjectNotFound;
            }
            if (cmt.UserId != userId)
            {
                return DatabaseActionOutcome.Forbidden;
            }
            Data.Comments.Remove(cmt);
            Data.SaveChanges();
            return DatabaseActionOutcome.Success;
        }