Example #1
0
        public LadderChange SaveCharacter(LadderChange change, QueueDodgeDB queueDodge)
        {
            var characterExists = queueDodge
                                  .Characters
                                  .Any(p => p.Name == change.Current.Character.Name &&
                                       p.RealmID == change.Current.Character.RealmID);

            if (!characterExists)
            {
                queueDodge.Entry(change.Current.Character).State = EntityState.Added;

                //var attachedCharacter = queueDodge.Add(change.Current.Character).Entity;
                queueDodge.SaveChanges();
            }

            var character = queueDodge
                            .Characters
                            .Include(p => p.Class)
                            .Include(p => p.Realm)
                            .Include(p => p.Specialization)
                            .Include(p => p.Race)
                            .Include(p => p.Realm.Region)
                            .Include(p => p.Race.Faction)
                            .Where(p => p.Name == change.Current.Character.Name &&
                                   p.RealmID == change.Current.Character.RealmID)
                            .Single();

            change.Current.Character  = character;
            change.Previous.Character = character;

            return(change);
        }
Example #2
0
        public async Task <IEnumerable <LadderChange> > DetectChanges(string bracket, Locale locale, BattleDotSwag.Region region)
        {
            var processed   = new List <Row>();
            var leaderboard = await GetActivity(bracket, locale, region);

            var activity      = Dedupe(leaderboard.Rows, processed);
            var entries       = ConvertToLadderEntry(activity, bracket, region);
            var cachedEntries = ExistsInCache(entries, cache);
            var changes       = CharacterChanged(cachedEntries);

            //  var x = leaderboard.Rows.Where(p => Dedupe(p, processed));



            foreach (var change in changes)
            {
                var change2    = SaveRealm(change, queueDodge);
                var change3    = SaveCharacter(change2, queueDodge);
                var fullChange = SaveLadderChange(change3, queueDodge);
                NotifyChanged(fullChange, sendMessage);
                queueDodge.SaveChanges();
            }

            return(changes.ToList());
        }
        private void Clear()
        {
            queueDodge.LadderChanges.Clear();
            queueDodge.Characters.Clear();
            queueDodge.Regions.Clear();
            queueDodge.Classes.Clear();
            queueDodge.Specializations.Clear();
            queueDodge.Races.Clear();
            queueDodge.Factions.Clear();
            queueDodge.Realms.Clear();

            queueDodge.SaveChanges();
        }
Example #4
0
        public LadderChange SaveRealm(LadderChange change, QueueDodgeDB queueDodge)
        {
            var realmExists = queueDodge
                              .Realms
                              .Any(p => p.ID == change.Current.Character.RealmID);

            if (!realmExists)
            {
                var realm = new Realm(change.Current.Character.RealmID,
                                      change.Current.Character.Realm.Name,
                                      change.Current.Character.Realm.Slug,
                                      change.Current.Character.Realm.RegionID);

                var trackedRealm = queueDodge.Realms.Add(realm);
                queueDodge.SaveChanges();
            }

            return(change);
        }