public static async Task InsertIntoLeaderBoardAsync(BoardEntry insertThis) { const string URL = "http://localhost:7071/api/InsertIntoLeaderboard"; using (var client = new HttpClient()) { await client.SendAsync(URL, insertThis); } }
static async Task Main() { Console.WriteLine("Hit any key to continue."); Console.ReadLine(); try { var date = new DateTime(2021, 1, 1); var b1 = new BoardEntry { UserId = 1, Email = "*****@*****.**", LastWorkout = date, Name = "Bob Jones", NumOfWorkouts = 61 }; var b2 = new BoardEntry { UserId = 2, Email = "*****@*****.**", LastWorkout = date, Name = "Sarah Smith", NumOfWorkouts = 73 }; var b3 = new BoardEntry { UserId = 3, Email = "*****@*****.**", LastWorkout = date, Name = "Jane Doe", NumOfWorkouts = 120 }; var b4 = new BoardEntry { UserId = 4, Email = "*****@*****.**", LastWorkout = date, Name = "Rich Crane", NumOfWorkouts = 229 }; var b5 = new BoardEntry { UserId = 5, Email = "*****@*****.**", LastWorkout = date, Name = "The Dude", NumOfWorkouts = 323 }; var b6 = new BoardEntry { UserId = 6, Email = "*****@*****.**", LastWorkout = date, Name = "John Pelak", NumOfWorkouts = 208 }; var b7 = new BoardEntry { UserId = 7, Email = "*****@*****.**", LastWorkout = date, Name = "Tim Cook", NumOfWorkouts = 20 }; var b8 = new BoardEntry { UserId = 8, Email = "*****@*****.**", LastWorkout = date, Name = "Johnathan Z", NumOfWorkouts = 2 }; var b9 = new BoardEntry { UserId = 9, Email = "*****@*****.**", LastWorkout = date, Name = "Claire Bridges", NumOfWorkouts = 50 }; var b10 = new BoardEntry { UserId = 10, Email = "*****@*****.**", LastWorkout = date, Name = "Ron Peter", NumOfWorkouts = 1 }; var b11 = new BoardEntry { UserId = 11, Email = "*****@*****.**", LastWorkout = date, Name = "Joe Dean", NumOfWorkouts = 0 }; await InsertIntoLeaderBoardAsync(b1); await InsertIntoLeaderBoardAsync(b2); await InsertIntoLeaderBoardAsync(b3); await InsertIntoLeaderBoardAsync(b4); await InsertIntoLeaderBoardAsync(b5); await InsertIntoLeaderBoardAsync(b6); await InsertIntoLeaderBoardAsync(b7); await InsertIntoLeaderBoardAsync(b8); await InsertIntoLeaderBoardAsync(b9); await InsertIntoLeaderBoardAsync(b10); await InsertIntoLeaderBoardAsync(b11); } catch { // FIRST TIME IN WORKS } var topTen = await GetTop10Async(); foreach (var b in topTen) { Console.WriteLine($"{b.User.Name} has {b.NumOfWorkouts} workouts."); } Console.WriteLine("Hit any key to exit."); Console.ReadLine(); }