Пример #1
0
 public LadderInspector(string apiKey, QueueDodgeDB queueDodge, IMemoryCache cache, Func <string, Task> sendMessage)
 {
     this.apiKey      = apiKey;
     this.queueDodge  = queueDodge;
     this.cache       = cache;
     this.sendMessage = sendMessage;
 }
Пример #2
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);
        }
Пример #3
0
        public LadderChange SaveLadderChange(LadderChange change, QueueDodgeDB queueDodge)
        {
            var changeModel = new LadderChangeModel(change);

            changeModel.CharacterID = change.Current.Character.ID;
            queueDodge.LadderChanges.Add(changeModel);

            return(change);
        }
Пример #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);
        }
Пример #5
0
 public QueueDodgeSeed(QueueDodgeDB queueDodge, IOptions <QueueDodgeOptions> options)
 {
     this.queueDodge = queueDodge;
     this.options    = options.Value;
 }