コード例 #1
0
        public async Task UpdateAsync(IContent content, string container)
        {
            if (content.Id == null)
            {
                throw new InvalidOperationException($"This content cannot be updated as it doesn't seem to exist (Id is null). Did you mean to use IContentCreator?");
            }

            var contentType = ContentTypeRepository.Get(content.ContentTypeId);

            if (contentType == null)
            {
                throw new InvalidOperationException($"This content has no content type (or rather its base class has no [ContentType] attribute)");
            }

            var document = ContentSerializer.Serialize(content, contentType);

            await DocumentUpdater.UpdateAsync(container, content.Id, document);
        }
コード例 #2
0
        public async Task UpdateAsync(IContent content)
        {
            if (content.Id == null)
            {
                throw new InvalidOperationException($"This content cannot be updated as it doesn't seem to exist (Id is null). Did you mean to use IContentCreator?");
            }

            var contentType = ContentTypeRepository.Get(content.ContentTypeId);

            if (contentType == null)
            {
                throw new TypeNotRegisteredContentTypeException(content.GetType());
            }

            foreach (var saveListener in SaveListenerProvider.GetFor(content))
            {
                saveListener.BeforeSave(content);
            }

            var document = ContentSerializer.Serialize(content, contentType);

            await DocumentUpdater.UpdateAsync(contentType.Container, content.Id, document);
        }