public string FixSeasonInReactions()
{
//This contoller method demonstrates the NEW DbContext.ChangeTracker.TrackGraph method
//(in the repo method that's called from here)
//which will iterate through all items in a graph and apply the specified
//function each item.
int totalDbRowsUpdated = 0;
var eventGraphs = _repo.GetAllEventsWithReactions();
foreach (var graph in eventGraphs.Where(e => e.Date.Month > 4))
{
foreach (var reaction in graph.Reactions)
{
if (reaction.Quote.ToUpper().Contains("SNOW"))
{
reaction.Quote = reaction.Quote.ToUpper().Replace("SNOW", "sun");
reaction.ObjectState = ObjectState.Modified;
}
}
var affectedRecords = _repo.UpdateRandomStateWeatherEventGraphs(eventGraphs);
totalDbRowsUpdated += affectedRecords;
}
return totalDbRowsUpdated.ToString();
}