/// <summary>
        /// Converts the specified issue to an anonymous object that can be safely serialized.
        /// </summary>
        /// <param name="issue">The issue to convert.</param>
        /// <param name="userId">The identifier of the currently logged-in user.</param>
        /// <returns></returns>
        async Task <object> AnonymousIssue(Issue issue, string userId)
        {
            AppUser assignee   = null;
            var     assigneeId = issue.AssignedToUserId;

            if (!string.IsNullOrEmpty(assigneeId))
            {
                assignee = await Db.Users.FindAsync(assigneeId);
            }

            var owned     = issue.UserId == userId;
            var overTaken = assigneeId == userId;

            // get the current user but make sure to avoid another round-trip to the database
            var user = assigneeId == userId
        ? assignee // assignee is the same as the current user
        : await Db.Users.FindAsync(userId);

            var canTake    = user.CanTakeOver(issue);
            var canComment = user.CanComment(issue);
            var comments   = await Db.QueryCommentsForIssue(issue.Id).ToArrayAsync();

            return(issue.AsDetail(comments, assignee?.FullName(), canTake, owned, overTaken, canComment));
        }