public async Task <bool> ApplyPromoCode(string code) { var result = false; try { var applied = await ApiService.ApplyPromoCode(code); result = applied.IsApplied; if (!applied.Message.IsNullOrEmpty()) { UserDialogs.Confirm(applied.Message, "ОК", !applied.IsApplied); } } catch (ConnectionException ex) { OnConnectionException(ex); } catch (Exception ex) { OnException(ex); } return(result); }
protected virtual async Task ProcessCardPayment(PaymentOrderInfo paymentInfo) { Loading = true; if (await VmService.PayWithCard(CardNumber.Without(' '), ExpirationDate, Cvv, CardHolder, paymentInfo.Amount, paymentInfo.Currency, () => { Loading = false; })) { UserDialogs.Confirm($"Заказ №{OrderId} успешно оплачен", "ОК"); //TODO переходить на экран успеха this.ChangePresentation(new MoveToDefaultPH()); } Loading = false; }
protected virtual async void RepeatOrder() { Loading = true; var response = await VmService.RepeatOrder(OrderId); Loading = false; if (response != null) { Messenger.Publish(new ProductAddToBasketMessage(this)); if (await UserDialogs.Confirm(response.Message, LocalizationService.GetLocalizableString(HistoryOrdersConstants.RESX_NAME, "HistoryOrderDetails_ToBasket"))) { var historyOrdersNavigationVmService = Mvx.Resolve <IHistoryOrdersNavigationVmService>(); historyOrdersNavigationVmService.NavigateToBasket(new BaseBundle(NavigationType.Push)); } } }
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 CheckRegion() { try { var detectedRegion = await ApiService.GetCurrentRegion(); if (AppSettings.RegionID != detectedRegion.Id) { if (AppSettings.RegionID == null) //first launch { AppSettings.RegionID = detectedRegion.Id; if (await UserDialogs.Confirm($"{LocalizationService.GetLocalizableString(SettingsConstants.RESX_NAME, "Region_YourCity")} {detectedRegion.Title}", LocalizationService.GetLocalizableString(SettingsConstants.RESX_NAME, "Region_Change"))) { NavigationService.NavigateToRegions(new SettingsPickerBundle(NavigationType.Push, detectedRegion.Id, detectedRegion.Title)); } } else //previous selection { var selectedRegion = await ApiService.GetRegion(AppSettings.RegionID); if (await UserDialogs.Confirm($"{LocalizationService.GetLocalizableString(SettingsConstants.RESX_NAME, "Region_YourCity")} {selectedRegion.Title}", LocalizationService.GetLocalizableString(SettingsConstants.RESX_NAME, "Region_Change"))) { NavigationService.NavigateToRegions(new SettingsPickerBundle(NavigationType.Push, detectedRegion.Id, detectedRegion.Title)); } } } } catch (ConnectionException ex) { OnConnectionException(ex); } catch (Exception ex) { OnException(ex); } }