Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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" }));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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 }));
        }
Exemplo n.º 5
0
        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));
        }