예제 #1
0
        public ActionResult New(string tabId, int parentId, int?groupId)
        {
            var content = VirtualContentService.New(parentId, groupId);
            var model   = VirtualContentViewModel.Create(content, tabId, parentId);

            return(JsonHtml("Properties", model));
        }
예제 #2
0
        public ActionResult Properties(string tabId, int parentId, int id, string successfulActionCode, bool?groupChanged)
        {
            var content = VirtualContentService.Read(id);
            var model   = VirtualContentViewModel.Create(content, tabId, parentId);

            model.GroupChanged        = groupChanged ?? false;
            model.SuccesfulActionCode = successfulActionCode;

            return(JsonHtml("Properties", model));
        }
예제 #3
0
        public ActionResult Properties(string tabId, int parentId, int id, string backendActionCode, FormCollection collection)
        {
            var content    = VirtualContentService.ReadForUpdate(id);
            var model      = VirtualContentViewModel.Create(content, tabId, parentId);
            var oldGroupId = model.Data.GroupId;

            TryUpdateModel(model);
            model.Validate(ModelState);
            if (ModelState.IsValid)
            {
                try
                {
                    model.Data = VirtualContentService.Update(model.Data);
                    PersistVirtualFieldIds(model.Data.NewVirtualFieldIds);
                }
                catch (UserQueryContentCreateViewException uqe)
                {
                    if (HttpContext.IsXmlDbUpdateReplayAction())
                    {
                        throw;
                    }

                    ModelState.AddModelError("UserQueryContentCreateViewException", uqe.Message);
                    return(JsonHtml("Properties", model));
                }
                catch (VirtualContentProcessingException vcpe)
                {
                    if (HttpContext.IsXmlDbUpdateReplayAction())
                    {
                        throw;
                    }

                    ModelState.AddModelError("VirtualContentProcessingException", vcpe.Message);
                    return(JsonHtml("Properties", model));
                }
                catch (CycleInContentGraphException)
                {
                    if (HttpContext.IsXmlDbUpdateReplayAction())
                    {
                        throw;
                    }

                    ModelState.AddModelError("CycleInContentGraphException", ContentStrings.CyclesInContentTree);
                    return(JsonHtml("Properties", model));
                }

                return(Redirect("Properties", new { tabId, parentId, id = model.Data.Id, successfulActionCode = backendActionCode, groupChanged = oldGroupId != model.Data.GroupId }));
            }

            return(JsonHtml("Properties", model));
        }
예제 #4
0
        public async Task <ActionResult> New(string tabId, int parentId, IFormCollection collection)
        {
            var content = VirtualContentService.NewForSave(parentId);
            var model   = VirtualContentViewModel.Create(content, tabId, parentId);

            await TryUpdateModelAsync(model);

            if (ModelState.IsValid)
            {
                try
                {
                    model.Data = VirtualContentService.Save(model.Data);
                    PersistResultId(model.Data.Id);
                    PersistVirtualFieldIds(model.Data.NewVirtualFieldIds);
                    return(Redirect("Properties", new { tabId, parentId, id = model.Data.Id, successfulActionCode = ActionCode.SaveVirtualContent }));
                }
                catch (UserQueryContentCreateViewException uqe)
                {
                    if (HttpContext.IsXmlDbUpdateReplayAction())
                    {
                        throw;
                    }

                    ModelState.AddModelError("UserQueryContentCreateViewException", uqe.Message);
                    return(await JsonHtml("Properties", model));
                }
                catch (VirtualContentProcessingException vcpe)
                {
                    if (HttpContext.IsXmlDbUpdateReplayAction())
                    {
                        throw;
                    }

                    ModelState.AddModelError("VirtualContentProcessingException", vcpe.Message);
                    return(await JsonHtml("Properties", model));
                }
                catch (CycleInContentGraphException)
                {
                    if (HttpContext.IsXmlDbUpdateReplayAction())
                    {
                        throw;
                    }

                    ModelState.AddModelError("CycleInContentGraphException", ContentStrings.CyclesInContentTree);
                    return(await JsonHtml("Properties", model));
                }
            }

            return(await JsonHtml("Properties", model));
        }