예제 #1
0
        private async void SaveClick()
        {
            RepositoryService.InitTable <ProfileModel>();
            if (IsButtonEnabled())
            {
                if (DateLabel == new DateTime())
                {
                    DateLabel = DateTime.Now;
                }

                int result = await RepositoryService.InsertAsync(new ProfileModel
                {
                    Id            = ProfileId,
                    NameLabel     = Name,
                    DateLabel     = DateLabel,
                    NickNameLabel = NickName,
                    ProfileImage  = profileImage,
                    Description   = Description,
                    UserId        = Settings.RememberedUserId
                });

                if (result != -1)
                {
                    var parameters = new NavigationParameters();
                    await NavigationService.GoBackAsync(parameters);
                }
            }
            else
            {
                UserDialogs.Alert(AppResources.FieldsFilled);
            }
        }
예제 #2
0
        protected async Task CheckPasswordAsync()
        {
            if (string.IsNullOrWhiteSpace(PasswordCell.Entry.Text))
            {
                await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired,
                                                                                  AppResources.MasterPassword), AppResources.Ok);

                return;
            }

            var key = _cryptoService.MakeKeyFromPassword(PasswordCell.Entry.Text, _authService.Email);

            if (key.SequenceEqual(_cryptoService.Key))
            {
                _settings.AddOrUpdateValue(Constants.Locked, false);
                await Navigation.PopModalAsync();
            }
            else
            {
                // TODO: keep track of invalid attempts and logout?

                UserDialogs.Alert(AppResources.InvalidMasterPassword);
                PasswordCell.Entry.Text = string.Empty;
                PasswordCell.Entry.Focus();
            }
        }
 private void Continue()
 {
     if (_dateTime.Date < DateTime.Now.Date)
     {
         // Date is in the past
         UserDialogs.Alert("Please select a date in the future");
     }
     else
     {
         ShowViewModel <TimeSelectViewModel>(new { roomId = _roomId, dateTime = _dateTime });
     }
 }
예제 #4
0
        protected void PinEntered(object sender, EventArgs args)
        {
            if (Model.PIN == _authService.PIN)
            {
                _settings.AddOrUpdateValue(Constants.Locked, false);
                PinControl.Entry.Unfocus();
                Navigation.PopModalAsync();
            }
            else
            {
                // TODO: keep track of invalid attempts and logout?

                UserDialogs.Alert(AppResources.InvalidPIN);
                Model.PIN = string.Empty;
                PinControl.Entry.Focus();
            }
        }
        protected virtual async void OnDeleteReview()
        {
            Loading = true;

            if (await VmService.DeleteReview(ReviewDetails.Id))
            {
                UserDialogs.Alert("Ваш отзыв удален");

                Close(this);
            }
            else
            {
                UserDialogs.Error("Не удалось удалить отзыв");
            }

            Loading = false;
        }
        public async Task <RegistrationResponse> SignUp(List <ISignUpItemBaseViewModel> fields, CancellationTokenSource cts)
        {
            try
            {
                var requestFields = new List <RegistrationRequestItem>();
                fields.ForEach(p =>
                {
                    if (!p.Internal)
                    {
                        requestFields.Add(new RegistrationRequestItem()
                        {
                            Type  = p.RegistrationField.Type,
                            Value = p.GetValue(),
                            Id    = p.RegistrationField.Id
                        });
                    }
                });
                var result = await AuthService.SignUp(requestFields, cts);

                if (result == null || !result.Successful)
                {
                    await UserDialogs.Alert(result?.Error ?? string.Empty);
                }
                else
                {
                    if (result.Successful)
                    {
                        await StartSession(result.Token);
                    }
                }

                return(result);
            }
            catch (ConnectionException ex)
            {
                OnConnectionException(ex);

                return(null);
            }
            catch (Exception ex)
            {
                OnException(ex);

                return(null);
            }
        }
예제 #7
0
        protected virtual async void OnPostReview()
        {
            Loading = true;

            if (await VmService.PostReview(ReviewId, ProductGroupId, ProductId, ReviewItems.OfType <IReviewParameterItemVm>().ToList()))
            {
                ChangePresentation(new NavigateToDefaultViewModelHint());

                UserDialogs.Alert("Ваш отзыв отправлен!");
            }
            else
            {
                UserDialogs.Error("Не удалось отправить отзыв");
            }

            Loading = false;
        }
        public async Task ResendCode(CancellationTokenSource cts)
        {
            try
            {
                await AuthService.ResendCode(cts);

                Mvx.Resolve <IMvxMainThreadDispatcher>().RequestMainThreadAction(() =>
                {
                    UserDialogs.Alert("Код подтверждения отправлен.");
                });
            }
            catch (ConnectionException ex)
            {
                OnConnectionException(ex);
            }
            catch (Exception ex)
            {
                OnException(ex);
            }
        }
        protected virtual void OnNext()
        {
            Task.Run(async() =>
            {
                if (!await ValidateAndSaveInput())
                {
                    return;
                }

                var oldDeliveyPrice = DeliveryPrice;
                DeliveryPrice       = await DeliveryVmService.LoadDeliveryPrice(DeliveryId);

                Mvx.Resolve <IMvxMessenger>().Publish(new DeliveryConfirmedMessage(this)
                {
                    DeliveryId    = DeliveryId,
                    DeliveryPrice = DeliveryPrice
                });

                if (DeliveryPrice.HasValue && oldDeliveyPrice != DeliveryPrice)
                {
                    if (VmNavigationType == NavigationType.PresentModal)
                    {
                        await UserDialogs.Alert($"{LocalizationService.GetLocalizableString(BasketConstants.RESX_NAME, "Order_DeliveryPriceAlert")} {DeliveryPrice.Value.ToString($"# ### ##0.## {AppSettings.SettingsCulture.NumberFormat.CurrencySymbol}").Trim()}");
                    }
                    else
                    {
                        await UserDialogs.Confirm($"{LocalizationService.GetLocalizableString(BasketConstants.RESX_NAME, "Order_DeliveryPriceAlert")} {DeliveryPrice.Value.ToString($"# ### ##0.## {AppSettings.SettingsCulture.NumberFormat.CurrencySymbol}").Trim()}", "Ок");
                    }
                }

                if (VmNavigationType == NavigationType.PresentModal)
                {
                    Close(this);
                }
                else
                {
                    NavigationVmService.NavigateToPayment(new PaymentBundle(DeliveryId, NavigationType.PresentModal));
                }
            });
        }
        public async Task SignInTo(OAuthType socialType, string cancelledError, string error, CancellationTokenSource cts)
        {
            try
            {
                var socialToken = await OAuthService.SignInTo(socialType);

                if (await OnSignInBySocial(socialToken, socialType, cts))
                {
                    await UserDialogs.Alert("Вы успешно выполнили вход");

                    ChangePresentation(new Base.Core.PresentationHints.NavigateToDefaultViewModelHint());
                }
            }
            catch (OperationCanceledException)
            {
                await UserDialogs.Alert(cancelledError);
            }
            catch (Exception ex)
            {
                OnException(ex, error);
            }
        }
예제 #11
0
        public async Task Init()
        {
            try
            {
                Locations = await PlatformService.GetLocationsAsync(ApiPriority.UserInitiated);

                _personalModel = await _userService.GetPersonalModelAsync(ApiPriority.UserInitiated);

                // Header image
                AvatarUrl = $"{_personalModel.Avatar.Medium}";

                // About
                DisplayName = _personalModel.DisplayName;
                FirstName   = _personalModel.FirstName;
                LastName    = _personalModel.LastName;
                Email       = _personalModel.Email;

                // Profile
                ShortIntro   = _personalModel.ShortAbout;
                About        = _personalModel.About;
                City         = _personalModel.City;
                LinkedInUrl  = _personalModel.LinkedInUrl;
                FacebookUrl  = _personalModel.FacebookUrl;
                TwitterUrl   = _personalModel.TwitterUrl;
                GoogleUrl    = _personalModel.GooglePlusUrl;
                InstagramUrl = _personalModel.InstagramUrl;

                SelectedLocation = Locations.Find(l => l.Id == _personalModel.LocationId);

                SelectedLanguage = Settings.SelectedLanguageId.ToString();

                OnEnableUpdate(false);
            }
            catch (Exception ex)
            {
                ExceptionService.HandleException(ex);
                UserDialogs.Alert(GetResource(ResKeys.mobile_error_server_error));
            }
        }
예제 #12
0
        public async Task Init()
        {
            try
            {
                _personalModel = await _userService.GetPersonalModelAsync(ApiPriority.UserInitiated);

                DisableAllMails           = _personalModel.NotificationSettings.DisableAllMails;
                DisableDailyDigest        = _personalModel.NotificationSettings.DisableDailyDigest;
                DisableNewFeedPost        = _personalModel.NotificationSettings.DisableNewFeedPost;
                DisableNewFeedPostComment = _personalModel.NotificationSettings.DisableNewFeedPostComment;
                DisableMention            = _personalModel.NotificationSettings.DisableMention;
                DisableAssigned           = _personalModel.NotificationSettings.DisableAssigned;
                DisableAdminMails         = _personalModel.NotificationSettings.DisableAdminMails;

                OnEnableUpdate(false);
            }
            catch (Exception ex)
            {
                Mvx.Resolve <IExceptionService>().HandleException(ex);
                UserDialogs.Alert(GetResource(ResKeys.mobile_error_server_error));
            }
        }
예제 #13
0
        protected void PinEntered(object sender, EventArgs args)
        {
            if (_lastAction.LastActionWasRecent())
            {
                return;
            }
            _lastAction = DateTime.UtcNow;

            if (Model.PIN == _authService.PIN)
            {
                _appSettingsService.Locked = false;
                PinControl.Entry.Unfocus();
                Navigation.PopModalAsync();
            }
            else
            {
                // TODO: keep track of invalid attempts and logout?

                UserDialogs.Alert(AppResources.InvalidPIN);
                Model.PIN = string.Empty;
                PinControl.Entry.Focus();
            }
        }
예제 #14
0
 public virtual void ShowError(Exception ex)
 {
     //some error message logic should be implemented here
     UserDialogs.Alert("Something went wrong");
 }