Beispiel #1
0
        private async System.Threading.Tasks.Task loadSettings()
        {
            this.IsBusy = true;
            try
            {
                if (CellPhoneCarriers.Count < 1)
                {
                    var carriers = await DataService.GetItemsAsync <CellPhoneCarrier>("cellPhoneCarriers");

                    carriers.Data.ForEach(d => this.CellPhoneCarriers.Add(d));
                }

                User = await DataService.GetItemAsync <User>("mySettings");

                User.CellPhoneCarrier = CellPhoneCarriers.FirstOrDefault(c => c.CellPhoneCarrierIdValue == User.CellPhoneCarrierIdValue);
                OnPropertyChanged("User");
                SettingsLoaded?.Invoke(this, new EventArgs());
            }
            catch (Exception ex)
            {
                IsBusy = false;
                ExceptionHelper.ShowException(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Beispiel #2
0
        private async System.Threading.Tasks.Task saveSettings()
        {
            if (!string.IsNullOrEmpty(this.User.Password))
            {
                if (this.User.Password != this.PasswordConfirm)
                {
                    MessageHelper.ShowMessage("Passwords do not match!", "Validation");
                    return;
                }
            }


            this.IsBusy = true;
            try
            {
                var forSave = Common.Clone <User>(User);
                forSave.CellPhoneCarrier = null;
                User = await DataService.PutItemAsync <User>("mySettings", User.UserIdValue, forSave);

                User.CellPhoneCarrier = CellPhoneCarriers.FirstOrDefault(c => c.CellPhoneCarrierIdValue == User.CellPhoneCarrierIdValue);
                LoginHelper.GetLoggedInUser().User = Common.Clone <User>(User);
                PasswordConfirm = string.Empty;
                OnPropertyChanged("User");
                OnPropertyChanged("PasswordConfirm");
                UserDialogs.Instance.Alert("Settings have been saved.");
            }
            catch (Exception ex)
            {
                IsBusy = false;
                ExceptionHelper.ShowException(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }