public void SaveDataFromMessageQueue() { while (true) { var game = messageQueueHandler.ReturnFirstGameInQueue(); var games = dbRepo.GetAllGames(); var similarGame = games.FirstOrDefault( g => g.CompetitionName == game.CompetitionName && g.SportType == game.SportType && g.Player1 == game.Player1 && g.Player2 == game.Player2 && Math.Abs((g.GameDate - game.GameDate).TotalDays) < 2); if (similarGame == null) { dbRepo.AddGame(game); } else if (similarGame.GameDate != game.GameDate) { similarGame.GameDate = game.GameDate; dbRepo.SaveChanges(); } } }
public IEnumerable <Game> GetAllGames() { return(storageRepo.GetAllGames()); }