public void Upsert(SOCStatistics s) { SOCStatistics existing; if (aggregates.TryGetValue(s.AggregateId, out existing)) { existing.Title = s.Title; existing.LastUpdated = s.LastUpdated; existing.NoOfUpdates = s.NoOfUpdates; } else { aggregates.Add(s.AggregateId, s); } }
public IActionResult AddSoc(SOC newSoc) { _data.AddOrUpdateSoc(newSoc,(newId)=> { //Update base query store var d = _data.GetSoc(newId); var state = new SOCState() { AggregateId=d.AggregateId,Title=d.Titel,LastUpdated=d.UpDateTime }; _queryStore.Upsert(state); var statistics=_data.GetList(newSoc.AggregateId).Count(); //update statistics store var stat = new SOCStatistics() { AggregateId = newSoc.AggregateId, Title = newSoc.Titel, LastUpdated = newSoc.UpDateTime, NoOfUpdates = statistics }; _statistics.Upsert(stat); }); return RedirectToAction("Index"); }
public SOCStatistics Get(Guid id) { SOCStatistics stat = new SOCStatistics(); aggregates.TryGetValue(id, out stat); return stat; }