Example #1
0
        public string DeleteEntity(int id)
        {
            var entity = GetEntity(id);

            if (entity == null)
            {
                return("Invalid id");
            }
            foreach (var field in entity.FieldMetadataRecords)
            {
                _contentDefinitionEditorEvents.CustomDeleteAction(field.ContentFieldDefinitionRecord.Name, field.Name, ParseSetting(field.Settings));
            }
            var hasPublished = entity.HasPublished();

            if (!hasPublished)
            {
                Services.ContentManager.Remove(entity.ContentItem);
            }
            else
            {
                _entityEvents.OnDeleting(entity.Name);
                _contentDefinitionService.RemoveType(entity.Name, true);
                _schemaUpdateService.DropTable(entity.Name);
            }
            Services.ContentManager.Remove(entity.ContentItem);

            return(null);
        }
Example #2
0
        public ActionResult Delete(string id)
        {
            if (!Services.Authorizer.Authorize(Permissions.EditContentTypes, T("无权限.")))
            {
                return(new HttpUnauthorizedResult());
            }

            var typeViewModel = _contentDefinitionService.GetType(id);

            if (typeViewModel == null)
            {
                return(HttpNotFound());
            }

            _contentDefinitionService.RemoveType(id, true);

            Services.Notifier.Information(T("\"{0}\" has been removed.", typeViewModel.DisplayName));

            return(RedirectToAction("List"));
        }
Example #3
0
        public async Task <ActionResult> Delete(string id)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.EditContentTypes))
            {
                return(Unauthorized());
            }

            var typeViewModel = _contentDefinitionService.GetType(id);

            if (typeViewModel == null)
            {
                return(NotFound());
            }

            _contentDefinitionService.RemoveType(id, true);

            _notifier.Success(T["\"{0}\" has been removed.", typeViewModel.DisplayName]);

            return(RedirectToAction("List"));
        }
Example #4
0
        public async Task <JsonResult> DestroyTypeContents()
        {
            var temp = this.DeserializeObject <IEnumerable <NewPartVM> >();

            foreach (var item in temp)
            {
                ContentItem DeviceItem = await _contentManager.GetAsync(item.NewID);

                if (_contentDefinitionManager.GetTypeDefinition(item.Name) == null)
                {
                }
                else
                {
                    _contentDefinitionService.RemoveType(item.Name, true);
                    _contentDefinitionService.RemovePartFromType(item.NewDisplayName, "新闻主页");
                }
                await _contentManager.RemoveAsync(DeviceItem);
            }
            return(this.Jsonp(temp));
        }