/// <summary> /// This method is responsible for handling the POST request of the step "Provide Address". In this method, we analyze the /// address and figure out whether we should be creating a new facility because the address doesn't yet exist in CERS. /// This method decides what view we progress to next... /// </summary> /// <param name="viewModel"></param> protected virtual void Handle_ProvideAddress(AddFacilityWizardViewModel viewModel) { //Step 1: Geocode/Wash address for the specified address. Services.ViewModels.Facility.Management.Geocode(viewModel); //Step 2: Find an existing Facility based on both washed and non-washed addresses. var potentialDuplicates = Services.Facilities.FindPotentialDuplicates(viewModel.State); //get the count of the potential duplicates. int potentialDuplicateCount = potentialDuplicates.Count(); //lets record the potential duplicate address count on the state bag for pick up in the UI and //for general recording of what we are doing. viewModel.State.PotentialDuplicateAddressCount = potentialDuplicateCount; if (potentialDuplicateCount > 0) { //show the choose existing facility view since we have potential duplicates for the address //provided by the user. viewModel.SetStep(AddFacilityWizardStep.ChooseExistingFacility); } else { //this looks like a unique address that does not already exist in CERS, so lets let the user proceed with //naming the facility... viewModel.SetStep(AddFacilityWizardStep.ProvideFacilityName); } //save our state as we move along through the wizard. Services.ViewModels.Facility.Management.SaveState(viewModel); }
protected virtual void Handle_ChooseExistingFacility(AddFacilityWizardViewModel viewModel) { //determine whether or not we have a selected CERSID if (viewModel.TargetCERSID.HasValue) { viewModel.State.CERSID = viewModel.TargetCERSID; //get the selected Facility var facility = Repository.Facilities.GetByID(viewModel.TargetCERSID.Value); if (facility != null) { //lets check to see if the current user already has access to this Facility via its associated organization. if (CurrentUserRoles.Contains(facility.CERSID, Context.Organization)) { viewModel.SetStep(AddFacilityWizardStep.FacilityExistsAlreadyBelongsToUsersOrganization); } else { viewModel.SetStep(AddFacilityWizardStep.FacilityExistsRequestAccessOrTransfer); } } else { //not sure yet what to do about this....it shouldn't happen, but you never know... } Services.ViewModels.Facility.Management.SaveState(viewModel); } }
protected virtual void Handle_ProvideFacilityName(AddFacilityWizardViewModel viewModel) { if (viewModel.State.OrganizationID.HasValue) { //In this case, we should create the Facility, because we know everything we need to //in order to do so. (The new facility should be added to the OrganizationID associated with //the state bag. //TODO: Create Facility viewModel.SetStep(AddFacilityWizardStep.NewFacilityAddedConfirmation); } else { //The user should be presented with a screen that les them see what the new facility is they are creating. //and allow them to verify the new Organization name/headquarter information. viewModel.SetStep(AddFacilityWizardStep.NewFacilityNewOrganization); } //save our state as we move along through the wizard. Services.ViewModels.Facility.Management.SaveState(viewModel); }
protected virtual void Handle_NewFacilityNewOrganization(AddFacilityWizardViewModel viewModel) { }
protected virtual void Handle_NewAdditionalFacilitySharesAddressWithAnotherFacility(AddFacilityWizardViewModel viewModel) { }
protected virtual void Handle_FacilityExistsRequestAccessOrTransfer(AddFacilityWizardViewModel viewModel) { }