예제 #1
0
        private static async Task ToDb(List <SaveAuction> auctions)
        {
            auctions = auctions.Distinct(new AuctionComparer()).ToList();
            lock (nameof(highestPlayerId))
            {
                if (highestPlayerId == 1)
                {
                    LoadFromDB();
                }
            }

            using (var context = new HypixelContext())
            {
                Dictionary <string, SaveAuction> inDb = await GetExistingAuctions(auctions, context);

                var comparer = new BidComparer();

                foreach (var auction in auctions)
                {
                    ProcessAuction(context, inDb, comparer, auction);
                }


                //Program.AddPlayers (context, playerIds);

                await context.SaveChangesAsync();

                context.Dispose();
            }
        }