/// <summary> /// Deletes all comments from a post /// </summary> /// <remarks>Used in conjunction with post deletion</remarks> /// <param name="postId"></param> public void DeleteCommentsByPostId(int postId) { var comments = _context.Comments.Where(p => p.PostId == postId); foreach (var comment in comments) { _context.Remove(comment); } }
/// <summary> /// Deletes user from database /// </summary> /// <param name="id">ID of the user to be deleted</param> public void DeleteUserByID(int id) { var entityToBeRemoved = _context.Users.Find(id); _context.Remove(entityToBeRemoved); }