private void DoSaveNewActionCommand() { // TODO: Need all the properties required for a new action. // TODO: Assumes you have already selected a valid projectId // TODO: OR you have single action project selected which means // TODO: I will create a NEW project/id for you and assign it to this action // TODO: Need better validation/error checking, etc. // TODO: Check, if record alreay exist with primary key guid // TODO: will it just save over the top of it or error? // TODO: For now, I am making this ViewModel go AWAY after you save it once // create a GTD Action to be added // Make sure we have an associated Project available string projectId; if (_isSingleActionProject) { var singleActionProject = new Project { TrustedSystemId = "1", ProjectId = Guid.NewGuid().ToString(), Outcome = _actionOutcome }; if (ValidateProject(singleActionProject)) { // Single-Action Project seems valid // so can save it and use it _projectService.DefineProject(singleActionProject); projectId = singleActionProject.ProjectId; } else { // TODO: what exception? how to handle? // return from Save method without saving for now. return; } } else { // user picked/created their own Project so use it projectId = _project.ProjectId; } // TODO: Hard coded to Trusted System 1 for now. var nextAction = new Action() { TrustedSystemId = "1", ActionId = Guid.NewGuid().ToString(), ProjectId = projectId, Outcome = _actionOutcome }; // if Validate is happy, save it if (!ValidateAction()) { return; } // validation of the Action was good _actionService.DefineAction(nextAction); // probably want to close our own ViewModel after // the "Add Screen" has finished with its purpose, adding the new Action // uses the Close method on the MvxNavigatingObject base class to close our MvxViewModel. // Close TRIES (can't guarantee it) within the platform-specific UI View layer to close // the current ViewModel. // TODO more on that later, depends on how you design UI. // Close sends a msg to the UI Layer and asks, // "Can you close the View that Corresponds to this ViewModel?" and makes best effort to do it. // On closure the previous ViewModel on nav stack should be displayed (likely InboxViewModel) // for now we will just delete stuff from the inbox if it // was successfully converted to an Action _inboxService.TrashStuff(ItemOfStuff); Close(this); }