private async Task ProcessAwards() { Log.Message(LogLevel.Info, "[ProcessAwards] - ProcessAwards started..."); var games = new List <GameModel>(); var clicks = new List <ClickModel>(); var pixels = new List <PixelModel>(); var awards = new List <AwardHistoryModel>(); Log.Message(LogLevel.Info, "[ProcessAwards] - Get process data started..."); using (var context = DataContextFactory.CreateReadOnlyContext()) { pixels = await context.PixelHistory //.Where(x => x.Game.Status == GameStatus.Started) .Select(x => new PixelModel { Id = x.Id, Type = PixelType.User, UserId = x.UserId, GameId = x.GameId, X = x.Pixel.X, Y = x.Pixel.Y, Color = x.Color, Points = x.Points, Timestamp = x.Timestamp }).ToListAsync(); pixels.AddRange ( await context.Pixel .Where(x => x.Type == PixelType.Fixed) .Select(x => new PixelModel { Id = x.Id, Type = PixelType.Fixed, UserId = 0, GameId = x.GameId, X = x.X, Y = x.Y, Color = x.Color, Points = x.Points, Timestamp = x.LastUpdate }).ToListAsync() ); clicks = await context.Click //.Where(x => x.Game.Status == GameStatus.Started) .Select(x => new ClickModel { Id = x.Id, UserId = x.UserId, GameId = x.GameId, ClickType = x.Type, X = x.X, Y = x.Y, Timestamp = x.Timestamp }).ToListAsync(); awards = await context.AwardHistory .Where(x => x.Award.Type.HasValue) .Select(x => new AwardHistoryModel { Id = x.Id, AwardId = x.AwardId, UserId = x.UserId, GameId = x.GameId, Version = x.Version, VersionData = x.VersionData, AwardType = x.Award.Type.Value, ClickType = x.Award.ClickType }).ToListAsync(); games = await context.Games .Where(x => x.Status == GameStatus.Started) .Select(x => new GameModel { Id = x.Id, Width = x.Width, Height = x.Height, EndType = x.EndType, EndTime = x.EndTime, Status = x.Status }).ToListAsync(); } Log.Message(LogLevel.Info, "[ProcessAwards] - Get process data complete."); await ClickAwardProcessor.ProcessClicks(games, clicks, awards); await PixelAwardProcessor.ProcessPixels(games, pixels, awards); await CheckGameEnd(games); Log.Message(LogLevel.Info, "[ProcessAwards] - ProcessAwards complete."); }