private void Create(ContentEvent @event, NamedContentData data) { var uniqueId = DomainId.Combine(@event.AppId, @event.ContentId); var state = new TextContentState { UniqueContentId = uniqueId }; state.GenerateDocIdCurrent(); Index(@event, new UpsertIndexEntry { ContentId = @event.ContentId, DocId = state.DocIdCurrent, GeoObjects = data.ToGeo(jsonSerializer), ServeAll = true, ServePublished = false, Texts = data.ToTexts(), IsNew = true }); states[state.UniqueContentId] = state; updates[state.UniqueContentId] = state; }
private void Update(ContentEvent @event, NamedContentData data) { var uniqueId = DomainId.Combine(@event.AppId, @event.ContentId); if (states.TryGetValue(uniqueId, out var state)) { if (state.DocIdNew != null) { Index(@event, new UpsertIndexEntry { ContentId = @event.ContentId, DocId = state.DocIdNew, GeoObjects = data.ToGeo(jsonSerializer), ServeAll = true, ServePublished = false, Texts = data.ToTexts() }); Index(@event, new UpdateIndexEntry { DocId = state.DocIdCurrent, ServeAll = false, ServePublished = true }); } else { var isPublished = state.DocIdCurrent == state.DocIdForPublished; Index(@event, new UpsertIndexEntry { ContentId = @event.ContentId, DocId = state.DocIdCurrent, GeoObjects = data.ToGeo(jsonSerializer), ServeAll = true, ServePublished = isPublished, Texts = data.ToTexts() }); } } }