private async Task SaveChange(LadderChange change) { data.LadderChanges.Add(change); await data.SaveChangesAsync(); }
private async Task CompareWithCache(LadderEntry entry, IMemoryCache cache, Func<string, Task> Send) { var key = entry.Request.RegionID + ":" + entry.RealmID + ":" + entry.Name; LadderEntry cachedEntry = default(LadderEntry); var cached = cache.TryGetValue(key, out cachedEntry); cache.Set(key, entry); if (cached) { var change = new LadderChange(cachedEntry, entry); if (change.Changed()) { SaveChange(change); BroadcastChange(change, Send); } } }
private async Task BroadcastChange(LadderChange change, Func<string, Task> Send) { var json = JsonConvert.SerializeObject(change); await Send(json); }