Esempio n. 1
0
        public async Task<ActionResult> RemovePartFromPOST(string id)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.EditContentTypes))
                return Unauthorized();

            var typeViewModel = _contentDefinitionService.GetType(id);

            var viewModel = new RemovePartViewModel();
            if (typeViewModel == null
                || !await TryUpdateModelAsync(viewModel)
                || !typeViewModel.TypeDefinition.Parts.Any(p => p.PartDefinition.Name == viewModel.Name))
                return NotFound();

            _contentDefinitionService.RemovePartFromType(viewModel.Name, typeViewModel.Name);

            if (!ModelState.IsValid)
            {
                _session.Cancel();
                viewModel.Type = typeViewModel;
                return View(viewModel);
            }

            _notifier.Success(T["The \"{0}\" part has been removed.", viewModel.Name]);

            return RedirectToAction("Edit", new { id });
        }
Esempio n. 2
0
        public async Task<ActionResult> RemovePartFrom(string id)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.EditContentTypes))
                return Unauthorized();

            var typeViewModel = _contentDefinitionService.GetType(id);

            var viewModel = new RemovePartViewModel();
            if (typeViewModel == null
                || !await TryUpdateModelAsync(viewModel)
                || !typeViewModel.TypeDefinition.Parts.Any(p => p.PartDefinition.Name == viewModel.Name))
                return NotFound();

            viewModel.Type = typeViewModel;
            return View(viewModel);
        }