コード例 #1
0
        public static async Task <int> GetUserId(ActionExecutingContext context, BitcornContext dbContext)
        {
            var platformHeaders = LockUserAttributeUtils.GetPlatformHeaders(context);

            switch (platformHeaders.Platform)
            {
            case "auth0":
                return(await dbContext.Auth0Query(platformHeaders.Id).Select(u => u.UserId).FirstOrDefaultAsync());

            case "twitch":
                return(await dbContext.TwitchQuery(platformHeaders.Id).Select(u => u.UserId).FirstOrDefaultAsync());

            case "discord":
                return(await dbContext.DiscordQuery(platformHeaders.Id).Select(u => u.UserId).FirstOrDefaultAsync());

            case "twitter":
                return(await dbContext.TwitterQuery(platformHeaders.Id).Select(u => u.UserId).FirstOrDefaultAsync());

            case "reddit":
                return(await dbContext.RedditQuery(platformHeaders.Id).Select(u => u.UserId).FirstOrDefaultAsync());

            default:
                return(0);
            }
        }
コード例 #2
0
        public static IQueryable <User> GetUserFromHeader(ActionExecutingContext context, BitcornContext dbContext)
        {
            var platformHeaders = LockUserAttributeUtils.GetPlatformHeaders(context);

            switch (platformHeaders.Platform)
            {
            case "auth0":
                return(dbContext.Auth0Query(platformHeaders.Id));

            case "twitch":
                return(dbContext.TwitchQuery(platformHeaders.Id));

            case "discord":
                return(dbContext.DiscordQuery(platformHeaders.Id));

            case "twitter":
                return(dbContext.TwitterQuery(platformHeaders.Id));

            case "reddit":
                return(dbContext.RedditQuery(platformHeaders.Id));

            default:
                return(null);
            }
        }