Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
        private void ChangeSettings(Settings settings, bool isPathChanged, bool isResolutionChanged)
        {
            this.settingsRepository.UpdateCurrentSettings(settings);

            if (isResolutionChanged)
            {
                ImageQuestionData.CurrentResolution = this.SelectedResolution;
            }

            GpsTracker.Instance.GpsAllowed = settings.IsGpsEnabled;

            this.Refresh();

            if (isPathChanged)
            {
                Membership.ResetCurrentUser();
                string navigationSource = string.Format(LOGIN_SOURCE, this.serverPath);
                NavigationProvider.Navigate(new System.Uri(navigationSource, System.UriKind.Relative));
                Locator.Cleanup();
            }
        }
        private void Refresh()
        {
            this.settingsRepository = new SettingsRepository();
            this.currentSettings = settingsRepository.GetCurrentSettings();
            this.Resolutions = new ObservableCollection<PhotoResolution>(settingsRepository.GetAvailablePhotoResolutions());

            this.IsCheckForNewSurveysOnStart = this.currentSettings.CheckForNewSurveys;
            this.IsGpsEnabled = this.currentSettings.IsGpsEnabled;
            this.SelectedResolution = this.Resolutions.SingleOrDefault(item => item.ID == this.currentSettings.PhotoResolutionID);
            this.UpdateLanguages();
            this.ServerPath = this.currentSettings.Server != null ? this.currentSettings.Server.Address : string.Empty;
            this.IsNeedUpdate = true;
            this.IsNeedUpdate = false;
        }
        private void LanguageSetCallback(bool result)
        {
            --BusyCount;
            if (result)
            {
                this.ServerPath = this.ServerPath.Trim();
                bool isPathChanged = IsServerPathChanged();
                bool isResolutionChanged = IsResolutionChanged();
                Settings settings = new Settings()
                {
                    IsGpsEnabled = this.IsGpsEnabled,
                    CheckForNewSurveys = this.IsCheckForNewSurveysOnStart,
                    LanguageID = this.CurrentLanguage.ID,
                    PhotoResolutionID = this.SelectedResolution.ID,
                    ServerID = currentSettings.Server.ID
                };

                if (IsServerPathChanged())
                {
                    Server newServer = serverRepository.TryGetServerByAddress(this.ServerPath);
                    if (newServer == null)
                    {
                        newServer = serverRepository.CreateServerByAddress(this.ServerPath);
                    }

                    settings.ServerID = newServer.ID;
                }

                this.ChangeSettings(settings, isPathChanged, isResolutionChanged);
                (Application.Current.Resources["LanguageStrings"] as LanguageStrings).RaiseAllPropertyChanged();
            }
            else
            {
                MessageBox.Show(UNABLE_DOWNLOAD_LANGUAGE);
            }

            this.SaveSettingsCommand.RaiseCanExecuteChanged();
        }
        private void OnDialogCompleted(object sender, ConfirmationResulEventArgs e)
        {
            if (e.DialogResult == Coding4Fun.Phone.Controls.PopUpResult.Ok)
            {                
                this.currentSettings = settingsRepository.ResetCurrentSettings();
                bool isServicePathChanged = this.currentSettings.Server.Address != this.ServerPath;
                SyncContext.Post((parameter) =>
                    {
                        if (isServicePathChanged)
                        {
                            Membership.ResetCurrentUser();
                            string navigationSource = string.Format(LOGIN_SOURCE, this.currentSettings.Server.Address);
                            NavigationProvider.Navigate(new System.Uri(navigationSource, System.UriKind.Relative));
                            Locator.Cleanup();
                        }
                        else
                        {
                            this.Refresh();
                        }

                    }, null);
            }
        }
 private void detach_Settings(Settings entity)
 {
     this.SendPropertyChanging();
     entity.Language = null;
 }
        public void InitializeViewModelExecute()
        {
            this.serverRepository = new ServerRepository();            
            this.settingsRepository = new SettingsRepository();

            currentSettings = settingsRepository.GetCurrentSettings();
            this.Refresh();
        }
 private void attach_Settings(Settings entity)
 {
     this.SendPropertyChanging();
     entity.Language = this;
 }
 partial void DeleteSettings(Settings instance);
 partial void UpdateSettings(Settings instance);
 partial void InsertSettings(Settings instance);
 private void detach_Settings(Settings entity)
 {
     this.SendPropertyChanging();
     entity.PhotoResolution = null;
 }