public ActionResult SaveForm(ViewModelRootContainer postedViewContainer) { DataSelectionViewModel currentViewModel = TempData[TempDataModelKey] as DataSelectionViewModel; // Reconcile changes BindToDataModel(currentViewModel, postedViewContainer); // Save changes foreach (IModelRootInstance instance in currentViewModel.CurrentSubject.Instances) { eavClient.SaveData(instance); } // Get rid of deleted items TrimDataModel(currentViewModel.CurrentContainer); // Refresh the view object currentViewModel.RegenerateViewContainer(); currentViewModel.CurrentViewContainer.DisplayMode = postedViewContainer.DisplayMode; currentViewModel.CurrentViewContainer.Enabled = postedViewContainer.Enabled; if (currentViewModel.CurrentViewContainer.DisplayMode != DisplayMode.Running) { currentViewModel.CurrentViewContainer.SelectedInstanceID = currentViewModel.CurrentViewContainer.Instances.Min(it => it.InstanceID.GetValueOrDefault()); currentViewModel.CurrentViewContainer.CurrentInstance = currentViewModel.CurrentViewContainer.Instances.SingleOrDefault(it => it.InstanceID == currentViewModel.CurrentViewContainer.SelectedInstanceID); } TempData[TempDataModelKey] = currentViewModel; return(RedirectToAction("PostRedirectGetTarget", new { view = currentViewModel.CurrentViewContainer.DisplayMode == DisplayMode.Singleton ? "DisplaySingletonContainer" : (currentViewModel.CurrentViewContainer.DisplayMode == DisplayMode.Recurring ? "DisplayRecurringContainer" : "DisplayRunningContainer") })); }
public ActionResult EditForm(DataSelectionViewModel postedModel) { DataSelectionViewModel currentViewModel = TempData[TempDataModelKey] as DataSelectionViewModel; // User's current choices currentViewModel.SelectedContainerID = postedModel.SelectedContainerID; currentViewModel.SelectedSubjectID = postedModel.SelectedSubjectID; LoadSelection(currentViewModel); // Refresh the view object currentViewModel.RegenerateViewContainer(); currentViewModel.CurrentViewContainer.DisplayMode = DisplayMode.Recurring; if (currentViewModel.CurrentViewContainer.DisplayMode != DisplayMode.Running) { currentViewModel.CurrentViewContainer.SelectedInstanceID = currentViewModel.CurrentViewContainer.Instances.Min(it => it.InstanceID.GetValueOrDefault()); currentViewModel.CurrentViewContainer.CurrentInstance = currentViewModel.CurrentViewContainer.Instances.SingleOrDefault(it => it.InstanceID == currentViewModel.CurrentViewContainer.SelectedInstanceID); } TempData[TempDataModelKey] = currentViewModel; return(RedirectToAction("PostRedirectGetTarget", new { view = currentViewModel.CurrentViewContainer.DisplayMode == DisplayMode.Singleton ? "DisplaySingletonContainer" : (currentViewModel.CurrentViewContainer.DisplayMode == DisplayMode.Recurring ? "DisplayRecurringContainer" : "DisplayRunningContainer") })); }