コード例 #1
0
        public object RemoveContent([FromBody] RemoveContentInput removeContentInput)
        {
            if (!ModelState.IsValid)
            {
                return(new
                {
                    success = false,
                    errors = ModelState.Values.SelectMany(v => v.Errors).Select(e => new { description = e.ErrorMessage }),
                });
            }

            var contentType = ContentTypeProvider.Get(removeContentInput.ContentTypeId);
            var content     = ContainerSpecificContentGetter.Get <IContent>(removeContentInput.Id, null, contentType.Container);

            if (content.ContentTypeId != contentType.Id)
            {
                throw new Exception($"Content is not of type {contentType.Id}");
            }

            ContainerSpecificContentDeleter.Delete(content.Id, contentType.Container);

            return(new
            {
                success = true,
            });
        }
コード例 #2
0
        public async Task <object> RemoveContent([FromBody] RemoveContentInput removeContentInput)
        {
            if (!ModelState.IsValid)
            {
                return(new
                {
                    success = false,
                    errors = ModelState.Values.SelectMany(v => v.Errors).Select(e => new { description = e.ErrorMessage }),
                });
            }

            await ContentDeleter.DeleteAsync(removeContentInput.ContentTypeId, PrimaryKeyConverter.Convert(removeContentInput.KeyValues, removeContentInput.ContentTypeId)).ConfigureAwait(false);

            return(new
            {
                success = true,
            });
        }