public ActionResult AddLayerPOST() { if (!IsAuthorizedToManageWidgets()) { return(new HttpUnauthorizedResult()); } LayerPart layerPart = _widgetsService.CreateLayer("", "", ""); if (layerPart == null) { return(HttpNotFound()); } var model = Services.ContentManager.UpdateEditor(layerPart, this); if (!ModelState.IsValid) { Services.TransactionManager.Cancel(); return(View(model)); } Services.Notifier.Information(T("Your {0} has been created.", layerPart.TypeDefinition.DisplayName)); return(RedirectToAction("Index", "Admin", new { layerId = layerPart.Id })); }
public ActionResult AddLayerPOST() { if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel))) { return(new HttpUnauthorizedResult()); } try { LayerPart layerPart = _widgetsService.CreateLayer("", "", ""); if (layerPart == null) { return(HttpNotFound()); } var model = Services.ContentManager.UpdateEditor(layerPart, this); if (!ModelState.IsValid) { Services.TransactionManager.Cancel(); // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation. return(View((object)model)); } Services.Notifier.Information(T("Your {0} has been created.", layerPart.TypeDefinition.DisplayName)); return(RedirectToAction("Index", "Admin", new { layerId = layerPart.Id })); } catch (Exception exception) { this.Error(exception, T("Creating layer failed: {0}", exception.Message), Logger, Services.Notifier); return(RedirectToAction("Index")); } }
public LayerPart GetContentLayer() { var contentLayer = _widgetsService.GetLayers().FirstOrDefault(x => x.Name == "ContentWidgets") ?? _widgetsService.CreateLayer("ContentWidgets", "This layer never activates, but is needed for the widgets hosted by content items for now.", "false"); return(contentLayer); }
public ActionResult AddLayerPOST() { if (!IsAuthorizedToManageWidgets()) { return(new HttpUnauthorizedResult()); } LayerPart layerPart = _widgetsService.CreateLayer("", "", ""); if (layerPart == null) { return(HttpNotFound()); } var model = Services.ContentManager.UpdateEditor(layerPart, this); if (!ModelState.IsValid) { Services.TransactionManager.Cancel(); // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation. return(View((object)model)); } Services.Notifier.Information(T("Your {0} has been created.", layerPart.TypeDefinition.DisplayName)); return(RedirectToAction("Index", "Admin", new { layerId = layerPart.Id })); }