public ActionResult DeleteChildContainer(ContainerViewModel postedModel) { MetadataModel metadata = TempData["Metadata"] as MetadataModel; metadata.DialogStack.Push(postedModel); IModelChildContainer eavContainer = FindContainer(metadata.CurrentContext.Containers, ID) as IModelChildContainer; if (eavContainer.ObjectState != ObjectState.New) { eavContainer.MarkDeleted(); } else { eavContainer.ParentContainer.ChildContainers.Remove(eavContainer); } TempData["Metadata"] = metadata; if (eavContainer.ParentContainer is IModelRootContainer) { return(BuildResult("Container Editor", Url.Content("~/Metadata/ContainerEditorDialog"), Url.Content("~/Metadata/UpdateRootContainer"), null)); } else { return(BuildResult("Container Editor", Url.Content("~/Metadata/ContainerEditorDialog"), Url.Content("~/Metadata/UpdateChildContainer"), null)); } }
public ActionResult AddChildContainer(ContainerViewModel postedModel) { MetadataModel metadata = TempData["Metadata"] as MetadataModel; postedModel.FixupContainerOrder(); postedModel.FixupAttributeOrder(); metadata.DialogStack.Push(postedModel); IModelContainer eavParentContainer = FindContainer(metadata.CurrentContext.Containers, postedModel.ID); IModelChildContainer eavChildContainer = objectFactory.Create <EAV.Model.IModelChildContainer>(); eavChildContainer.ContainerID = metadata.NextContainerID; eavChildContainer.ParentContainer = eavParentContainer; eavChildContainer.Sequence = eavParentContainer.ChildContainers.Max(it => it.Sequence) + 1; metadata.DialogStack.Push(new ContainerViewModel(eavChildContainer)); TempData["Metadata"] = metadata; return(BuildResult("Container Editor", Url.Content("~/Metadata/ContainerEditorDialog"), Url.Content("~/Metadata/UpdateChildContainer"), null)); }
public ActionResult UpdateChildContainer(ContainerViewModel postedModel) { MetadataModel metadata = TempData["Metadata"] as MetadataModel; IModelChildContainer eavContainer = FindContainer(metadata.CurrentContext.Containers, postedModel.ID) as IModelChildContainer; if (UpdateRequested) { eavContainer.Name = postedModel.Name; eavContainer.DataName = postedModel.DataName; eavContainer.DisplayText = postedModel.DisplayText; eavContainer.IsRepeating = postedModel.IsRepeating; foreach (AttributeViewModel attributeModel in postedModel.Attributes) { eavContainer.Attributes.Single(it => it.AttributeID == attributeModel.ID).Sequence = attributeModel.Sequence; } foreach (ContainerViewModel containerModel in postedModel.ChildContainers) { eavContainer.ChildContainers.Single(it => it.ContainerID == containerModel.ID).Sequence = containerModel.Sequence; } } else if (eavContainer.ObjectState == ObjectState.New && (String.IsNullOrWhiteSpace(eavContainer.Name) || (String.IsNullOrWhiteSpace(eavContainer.DataName))) && !eavContainer.ChildContainers.Any()) { eavContainer.ParentContainer.ChildContainers.Remove(eavContainer); } TempData["Metadata"] = metadata; if (eavContainer.ParentContainer is IModelRootContainer) { return(BuildResult("Container Editor", Url.Content("~/Metadata/ContainerEditorDialog"), Url.Content("~/Metadata/UpdateRootContainer"), null)); } else { return(BuildResult("Container Editor", Url.Content("~/Metadata/ContainerEditorDialog"), Url.Content("~/Metadata/UpdateChildContainer"), null)); } }
public static ViewModelContainer Create(IModelChildContainer container, IModelSubject subject, ViewModelInstance parentInstance, ref int nextInstanceID) { ViewModelContainer viewContainer = new ViewModelContainer() { ContainerID = container.ContainerID, ParentContainerID = container.ParentContainerID, DisplayText = container.DisplayText, IsRepeating = container.IsRepeating }; foreach (IModelInstance instance in container.Instances.Where(it => it.ParentInstanceID == parentInstance.InstanceID)) { ViewModelInstance viewInstance = ViewModelInstance.Create(container, subject, instance, parentInstance, ref nextInstanceID); viewContainer.Instances.Add(viewInstance); } if (container.IsRepeating || !viewContainer.Instances.Any()) { ViewModelInstance viewInstance = ViewModelInstance.Create(container, subject, null, parentInstance, ref nextInstanceID); viewContainer.Instances.Add(viewInstance); } return(viewContainer); }