public void WeedOutGames() { foreach (var entity in context.SMGamesWithCards.ToList()) { context.SMGamesWithCards.Remove(entity); } List <SMGameAndCards> gamesAndCards = new List <SMGameAndCards>(); foreach (var game in Games) { List <double> cardPrices = GetCardPrices(game, out int cardsCount); double sumOfAdditionalCards = (cardsCount != cardPrices.Count) ? (cardsCount - cardPrices.Count) * cardPrices.Last() : 0; double cardsAvgPrice = (cardPrices.Sum() + sumOfAdditionalCards) / cardsCount; double chanceToPayOff = GetChanceToPayOff(game.Price, cardPrices, cardsCount); gamesAndCards.Add(new SMGameAndCards { Game = game, CardsCount = cardsCount, CardsAveragePrice = cardsAvgPrice, ChanceToPayOff = chanceToPayOff }); } foreach (var game in gamesAndCards) { context.SMGamesWithCards.Add(game); } context.SaveChanges(); }
public void ReloadGamesDB(double maxPrice) { foreach (var entity in context.SSGames.ToList()) { context.SSGames.Remove(entity); } foreach (var game in SteamShopParse(maxPrice)) { context.SSGames.Add(game.Value); } context.SaveChanges(); }