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); }
public LadderChange SaveLadderChange(LadderChange change, QueueDodgeDB queueDodge) { var changeModel = new LadderChangeModel(change); changeModel.CharacterID = change.Current.Character.ID; queueDodge.LadderChanges.Add(changeModel); return(change); }
public IEnumerable <LadderChange> CharacterChanged(IEnumerable <LadderEntryPair> source) { foreach (var pair in source) { var change = new LadderChange(pair.Cached, pair.Current); if (change.Changed()) { yield return(change); } } }
public LadderChange NotifyChanged(LadderChange change, Func <string, Task> sendMessage) { var options = new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver() }; var json = JsonConvert.SerializeObject(change, options); sendMessage(json); return(change); }
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); }