示例#1
0
        public void SyncSets()
        {
            var excludedTypes = new List <string>
            {
                "funny",
                "token"
            };
            var apiSets = _scryfall.GetSets().Where(s => !excludedTypes.Contains(s.SetType)).ToList();

            System.Console.WriteLine($"found {apiSets.Count} sets from API");
            var dbSets = _db.Sets().ToList();

            System.Console.WriteLine($"found {dbSets.Count} sets from DB");
            var setsToAdd = apiSets.Where(a => !dbSets.Any(d => d.Id == a.Id));

            foreach (var newSet in setsToAdd)
            {
                System.Console.WriteLine($"Attempting to add set '{newSet.Name}'");
                _db.AddSet(SetMapper.SharedToDb(newSet));
            }
        }