public ActionResult Edit(string moduleName, string contentTypeFullName = null, Guid?baseContentTypeId = null) { //TODO: Validation, etc. //TODO: BaseContentType ContentType contentType = null; if (!contentTypeFullName.IsNullOrEmpty()) { contentType = _reflectionContentManager.LoadContentType(contentTypeFullName); } if (contentType == null && moduleName.IsNullOrEmpty()) { throw new NotImplementedException(); } /* _reflectionContentManager.GetModuleNameFromContentTypeFullName(contentTypeFullName);*/ var viewModel = new EditContentTypeViewModel(); if (contentType != null) { viewModel.Name = contentType.Name; viewModel.ModuleName = contentType.Module.Name; } else { viewModel.ModuleName = moduleName; } return(View(viewModel)); }
public async Task <IActionResult> Edit(EditContentTypeViewModel viewModel) { SpeedWagonContent contentType = await this._speedWagon.ContentTypeService.Get(viewModel.Name); if (!ModelState.IsValid) { IEnumerable <SpeedWagonContent> editors = await this._speedWagon.EditorService.List(); IEnumerable <SpeedWagonContent> contentTypes = await this._speedWagon.ContentTypeService.List(); viewModel.ContentType = contentType; viewModel.Root = contentType.GetValue <bool>("Root"); viewModel.Children = contentType.GetValue <string[]>("Children"); viewModel.Name = contentType.Name; viewModel.Url = contentType.RelativeUrl; viewModel.AvailableContentTypes = SelectListHelper.GetSelectList(contentTypes); viewModel.AvailableEditors = SelectListHelper.GetSelectList(editors); viewModel.Editors = this._speedWagon.ContentTypeService.GetEditors(contentType); return(View(viewModel)); } contentType.Content["Root"] = viewModel.Root; contentType.Content["Children"] = viewModel.Children; this._speedWagon.ContentTypeService.Save(contentType, User.Identity.Name.MaskEmail()); return(RedirectToAction("Edit", new { url = contentType.Name, operation = "edited" })); }
public ActionResult Edit(EditContentTypeViewModel viewModel) { //TODO: Validation, etc. //TODO: BaseContentType var module = _reflectionContentManager.LoadModule(viewModel.ModuleName); module.AddContentType(viewModel.Name); _reflectionContentManager.Store(module); _reflectionContentManager.SaveChanges(); return(Redirect("/admin/module?modulename=" + viewModel.ModuleName)); }
public async Task <IActionResult> AddProperty(EditContentTypeViewModel viewModel) { SpeedWagonContent contentType = await this._speedWagon.ContentTypeService.Get(viewModel.Url); if (!ModelState.IsValid) { IEnumerable <SpeedWagonContent> editors = await this._speedWagon.EditorService.List(); viewModel.ContentType = contentType; viewModel.Name = contentType.Name; viewModel.AvailableEditors = SelectListHelper.GetSelectList(editors); viewModel.Editors = this._speedWagon.ContentTypeService.GetEditors(contentType); return(View(viewModel)); } this._speedWagon.ContentTypeService.AddEditor(contentType, viewModel.ContentTypeEditor); this._speedWagon.ContentTypeService.Save(contentType, User.Identity.Name.MaskEmail()); return(RedirectToAction("Edit", new { url = viewModel.Url })); }
public async Task <IActionResult> Edit(string url, string operation = null) { SpeedWagonContent contentType = await this._speedWagon.ContentTypeService.Get(url); IEnumerable <SpeedWagonContent> editors = await this._speedWagon.EditorService.List(); IEnumerable <SpeedWagonContent> contentTypes = await this._speedWagon.ContentTypeService.List(); EditContentTypeViewModel viewModel = new EditContentTypeViewModel(); viewModel.Operation = operation; viewModel.ContentType = contentType; viewModel.Root = contentType.GetValue <bool>("Root"); viewModel.Children = contentType.GetValue <string[]>("Children"); viewModel.Name = contentType.Name; viewModel.Url = url; viewModel.AvailableContentTypes = SelectListHelper.GetSelectList(contentTypes); viewModel.AvailableEditors = SelectListHelper.GetSelectList(editors); viewModel.Editors = this._speedWagon.ContentTypeService.GetEditors(contentType); return(View("~/Views/SpeedWagon/ContentType/Edit.cshtml", viewModel)); }