// create / update an event // the system doesn't really distinguish between the two, just to keep the logic simple // scenarios include changing the start or end date, changing the list of topics for that event, etc public async Task Update(string title, string type, string start, string end, TopicApiData[] topics) { string id = this.GetPrimaryKeyString(); // rmember - the grain key is the event id Console.WriteLine($"** EventGrain Update()for event id = {id}, with title {title}"); // update interal grain state State.title = title; State.type = type; State.start = start; State.end = end; State.topics = topics; State.feedback = new List <FeedbackGrainState>(); // lets clear all feedback, just to keep things simple Console.WriteLine($"** EventGrain Update() about to write WriteStateAsync"); await base.WriteStateAsync(); // update aggregator about this new event SummaryEventInfo eventInfo = new SummaryEventInfo(); eventInfo.id = id; eventInfo.title = title; eventInfo.start = start; eventInfo.end = end; IAggregatorGrain aggregator = GrainFactory.GetGrain <IAggregatorGrain>(Guid.Empty); // the aggregator grain is a singleton - Guid.Empty is convention to indicate this //await aggregator.DeleteAnEvent(id); await aggregator.AddAnEvent(eventInfo); return; }