public ActionResult Properties(string tabId, int parentId, int id, string backendActionCode, FormCollection collection) { var field = FieldService.ReadForUpdate(id); var model = FieldViewModel.Create(field, tabId, parentId); var oldOrder = model.Data.Order; var oldViewInList = model.Data.ViewInList; var oldLinkId = model.Data.LinkId; var oldBackward = model.Data.BackwardField; TryUpdateModel(model); model.Validate(ModelState); if (ModelState.IsValid) { try { model.Data = FieldService.Update(model.Data); PersistLinkId(oldLinkId, model.Data.LinkId); PersistBackwardId(oldBackward, model.Data.BackwardField); PersistVirtualFieldIds(model.Data.NewVirtualFieldIds); AppendFormGuidsFromIds("DefaultArticleIds", "DefaultArticleUniqueIds"); AppendFormGuidsFromIds("Data.O2MDefaultValue", "Data.O2MUniqueIdDefaultValue"); } catch (UserQueryContentCreateViewException uqEx) { if (HttpContext.IsXmlDbUpdateReplayAction()) { throw; } ModelState.AddModelError("UserQueryContentCreateViewException", uqEx.Message); return(JsonHtml("Properties", model)); } catch (VirtualContentProcessingException vcpEx) { if (HttpContext.IsXmlDbUpdateReplayAction()) { throw; } ModelState.AddModelError("VirtualContentProcessingException", vcpEx.Message); return(JsonHtml("Properties", model)); } var newOrder = model.Data.Order; var newViewInList = model.Data.ViewInList; return(Redirect("Properties", new { tabId, parentId, id = model.Data.Id, successfulActionCode = backendActionCode, orderChanged = newOrder != oldOrder, viewInListAffected = newViewInList != oldViewInList })); } return(JsonHtml("Properties", model)); }
public ActionResult VirtualProperties(string tabId, int parentId, int id, FormCollection collection) { var field = FieldService.ReadForUpdate(id); var model = FieldViewModel.Create(field, tabId, parentId); var oldOrder = model.Data.Order; var oldViewInList = model.Data.ViewInList; TryUpdateModel(model); model.Validate(ModelState); if (ModelState.IsValid) { try { model.Data = VirtualFieldService.Update(model.Data); PersistVirtualFieldIds(model.Data.NewVirtualFieldIds); } catch (UserQueryContentCreateViewException uqe) { if (HttpContext.IsXmlDbUpdateReplayAction()) { throw; } ModelState.AddModelError("UserQueryContentCreateViewException", uqe.Message); return(JsonHtml("VirtualProperties", model)); } catch (VirtualContentProcessingException vcpe) { if (HttpContext.IsXmlDbUpdateReplayAction()) { throw; } ModelState.AddModelError("VirtualContentProcessingException", vcpe.Message); return(JsonHtml("Properties", model)); } var newViewInList = model.Data.ViewInList; return(Redirect("VirtualProperties", new { tabId, parentId, id = model.Data.Id, successfulActionCode = ActionCode.UpdateField, orderChanged = oldOrder != model.Data.Order, viewInListAffected = newViewInList != oldViewInList })); } return(JsonHtml("VirtualProperties", model)); }