public void UpdateCredentialInformation(FedExCredentialsData NewFedExData) { if (!String.IsNullOrWhiteSpace(NewFedExData.UserKey)) { FedEx.UserKey = NewFedExData.UserKey; } if (!String.IsNullOrWhiteSpace(NewFedExData.UserPassword)) { FedEx.UserPassword = NewFedExData.UserPassword; } if (!String.IsNullOrWhiteSpace(NewFedExData.AccountNumber)) { FedEx.AccountNumber = NewFedExData.AccountNumber; } if (!String.IsNullOrWhiteSpace(NewFedExData.MeterNumber)) { FedEx.MeterNumber = NewFedExData.MeterNumber; } }
public void UpdateCredentialInformation(FedExCredentialsData NewFedExData) { if (!String.IsNullOrWhiteSpace(NewFedExData.UserKey)) { FedEx.UserKey = NewFedExData.UserKey; } if (!String.IsNullOrWhiteSpace(NewFedExData.UserPassword)) { FedEx.UserPassword = NewFedExData.UserPassword; } if (!String.IsNullOrWhiteSpace(NewFedExData.AccountNumber)) { FedEx.AccountNumber = NewFedExData.AccountNumber; } if (!String.IsNullOrWhiteSpace(NewFedExData.MeterNumber)) { FedEx.MeterNumber = NewFedExData.MeterNumber; } }
private void UpdateFedExAccount_Click(object sender, RoutedEventArgs e) { //show progress bar Progress.Visibility = System.Windows.Visibility.Visible; if (UpdateFedExToDefaults_CheckBox.IsChecked == false) { var NewFedExData = new FedExCredentialsData(); //Populate object with updated values NewFedExData.UserKey = FedExUserKEY.Text; NewFedExData.UserPassword = FedExUserPASSWORD.Text; NewFedExData.AccountNumber = FedExUserACCOUNTNUMBER.Text; NewFedExData.MeterNumber = FedExUserMETERNUMBER.Text; //Send new information to FedExManager via TrackingControl TrackingServiceControl.UpdateCredentialInformation(NewFedExData); //Update the database with the new credentials StoreAndUpdateCredentials(NewFedExData); //Clear entry fields FedExUserKEY.Text = ""; FedExUserPASSWORD.Text = ""; FedExUserMETERNUMBER.Text = ""; FedExUserACCOUNTNUMBER.Text = ""; } else { //Trigger a reset credentials to default in memory TrackingServiceControl.ResetCredentialsToDefaults(ParcelService.FedEx); //Trigger a reset to defaults in database ResetCredentialsInDBToDefaults(ParcelService.FedEx); //Blank fields on reset to defaults, and uncheck box FedExUserKEY.Text = ""; FedExUserPASSWORD.Text = ""; FedExUserMETERNUMBER.Text = ""; FedExUserACCOUNTNUMBER.Text = ""; UpdateFedExToDefaults_CheckBox.IsChecked = false; } FedExCredentialEntry_PopUp.IsOpen = false; ProgressBarVisibilityDelay(); }
private void ResetCredentialsInDBToDefaults(ParcelService Service) { var CurrentDBList = DBContext.Credentials.ToList(); foreach (CredentialData credentials in CurrentDBList) { if (Service == ParcelService.FedEx) { var DefaultCredentials = new FedExCredentialsData(); credentials.FedExCredentials.UserKey = DefaultCredentials.UserKey; credentials.FedExCredentials.UserPassword = DefaultCredentials.UserPassword; credentials.FedExCredentials.AccountNumber = DefaultCredentials.AccountNumber; credentials.FedExCredentials.MeterNumber = DefaultCredentials.MeterNumber; } if (Service == ParcelService.UPS) { var DefaultCredentials = new UPSCredentialsData(); credentials.UPSCredentials.Username = DefaultCredentials.Username; credentials.UPSCredentials.Password = DefaultCredentials.Password; credentials.UPSCredentials.AccessLicenseNumber = DefaultCredentials.AccessLicenseNumber; } if (Service == ParcelService.USPS) { var DefaultCredentials = new USPSCredentialsData(); credentials.POSTALCredentials.UserID = DefaultCredentials.UserID; } } DBContext.SaveChanges(); }
private void RetrieveCredentialsOnLoad() { var CurrentDBList = DBContext.Credentials.ToList(); foreach (CredentialData credentials in CurrentDBList) { FedExCredentialsData NewFedExData = new FedExCredentialsData(); NewFedExData.UserKey = (B64Decode(credentials.FedExCredentials.UserKey)); NewFedExData.UserPassword = (B64Decode(credentials.FedExCredentials.UserPassword)); NewFedExData.AccountNumber = (B64Decode(credentials.FedExCredentials.AccountNumber)); NewFedExData.MeterNumber = (B64Decode(credentials.FedExCredentials.MeterNumber)); TrackingServiceControl.UpdateCredentialInformation(NewFedExData); UPSCredentialsData NewUPSData = new UPSCredentialsData(); NewUPSData.Username = (B64Decode(credentials.UPSCredentials.Username)); NewUPSData.Password = (B64Decode(credentials.UPSCredentials.Password)); NewUPSData.AccessLicenseNumber = (B64Decode(credentials.UPSCredentials.AccessLicenseNumber)); TrackingServiceControl.UpdateCredentialInformation(NewUPSData); USPSCredentialsData NewUSPSData = new USPSCredentialsData(); NewUSPSData.UserID = (B64Decode(credentials.POSTALCredentials.UserID)); TrackingServiceControl.UpdateCredentialInformation(NewUSPSData); } }
private void StoreAndUpdateCredentials(FedExCredentialsData NewFedExData) { var CurrentDBList = DBContext.Credentials.ToList(); foreach (CredentialData credentials in CurrentDBList) { credentials.FedExCredentials.UserKey = B64Encode(NewFedExData.UserKey); credentials.FedExCredentials.UserPassword = B64Encode(NewFedExData.UserPassword); credentials.FedExCredentials.AccountNumber = B64Encode(NewFedExData.AccountNumber); credentials.FedExCredentials.MeterNumber = B64Encode(NewFedExData.MeterNumber); } DBContext.SaveChanges(); }