Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var request = new LeagueRequest {
                LeagueId = 5, Initialize = true
            };

            Updater.UpdateLeague(request).Wait();

            //var updater = Updater.Init();
            //updater.Update();
        }
Ejemplo n.º 2
0
        public static async Task UpdateLeague(LeagueRequest request)
        {
            var builder = new ConfigurationBuilder()
                          .AddEnvironmentVariables();
            var configuration = builder.Build();

            var serviceProvider = new ServiceCollection()
                                  .AddOptions()
                                  .AddSingleton <StatsProvider>()
                                  .AddAuth0Client(configuration)
                                  .AddStaplePuckClient(configuration)
                                  .BuildServiceProvider();

            var provider = serviceProvider.GetService <StatsProvider>();

            var league = await provider.GetLeagueStats(request.LeagueId);

            var playerScores = await provider.GeneratePlayerScores(league, request.Initialize);

            var teamScores = await provider.GenerateTeamScores(league, playerScores);

            var leagueScore = new Data.LeagueScore
            {
                Id = request.LeagueId,
                PlayerCalculatedScores = playerScores,
                FantasyTeams           = teamScores
            };
            var client = serviceProvider.GetService <IStaplePuckClient>();
            var result = await client.UpdateAsync("updateLeagueScores", leagueScore, "league");

            if (result == null)
            {
                Console.Error.WriteLine("Null result");
            }
            else if (!result.Success)
            {
                Console.Error.WriteLine($"Failed to update. Message {result.Message}");
            }
        }
Ejemplo n.º 3
0
 public async Task ProcessRequest(LeagueRequest request, ILambdaContext context)
 {
     await Updater.UpdateLeague(request);
 }