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 })); }
public ActionResult RemovePartFromPOST(string id) { if (!Services.Authorizer.Authorize(Permissions.EditContentTypes, T("Not allowed to edit a content type."))) { return(new HttpUnauthorizedResult()); } var typeViewModel = _contentDefinitionService.GetType(id); var viewModel = new RemovePartViewModel(); if (typeViewModel == null || !TryUpdateModel(viewModel) || !typeViewModel.Parts.Any(p => p.PartDefinition.Name == viewModel.Name)) { return(HttpNotFound()); } _contentDefinitionService.RemovePartFromType(viewModel.Name, typeViewModel.Name); if (!ModelState.IsValid) { Services.TransactionManager.Cancel(); viewModel.Type = typeViewModel; return(View(viewModel)); } Services.Notifier.Information(T("The \"{0}\" part has been removed.", viewModel.Name)); return(RedirectToAction("Edit", new { id })); }
public IActionResult Index() { var viewModel = new RemovePartViewModel { AllParts = this.removePartService.GetAllParts(), }; var model = new RemovePartBaseModel { RemovePartInputModel = new RemovePartInputModel(), RemovePartViewModel = viewModel, }; return(this.View(model)); }
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)); }
public ActionResult RemovePartFrom(string id) { if (!Services.Authorizer.Authorize(Permissions.EditContentTypes, T("Not allowed to edit a content type."))) { return(new HttpUnauthorizedResult()); } var typeViewModel = _contentDefinitionService.GetType(id); var viewModel = new RemovePartViewModel(); if (typeViewModel == null || !TryUpdateModel(viewModel) || !typeViewModel.Parts.Any(p => p.PartDefinition.Name == viewModel.Name)) { return(HttpNotFound()); } viewModel.Type = typeViewModel; return(View(viewModel)); }