public async void Login() { try { if (CurrentRole.Value.Equals(RolesEnum.Продавец.ToString())) { roleLog <MainViewModel>(_loginService); } else if (CurrentRole.Value.Equals(RolesEnum.Управляющий.ToString())) { roleLog <StatisticOwnerViewModel>(_ownerAuthService); } else { var toastConfig = new ToastConfig("Выберете роль!") { BackgroundColor = Color.DarkRed }; this._userArcDialogs.Toast(toastConfig); } } catch (System.Exception) { _userArcDialogs.Loading().Hide(); _userArcDialogs.Alert("Ошибка авторизации", "Неправильный логин или пароль"); } }
private async Task SearchCountry() { if (IsBusy) { return; } try { if (string.IsNullOrEmpty(Country) == false) { using (dialogs.Loading()) { IsBusy = true; var response = await countriesService.GetByName(Country); var countries = mapper.Map <List <CountryViewModel> >(response); AddCountries(countries); } } } catch (Exception ex) { await pageDialogService.DisplayAlertAsync("IG", ex.Message, "OK"); } finally { IsBusy = false; } }
/// <summary> /// milliseconds 秒経っても task が完了しない場合、Loading ダイアログを完了まで表示 /// </summary> public static Task <T> LoadingDelayedAsync <T>(this IUserDialogs instance, Task <T> task, CancellationTokenSource source, string title = "", string cancelText = null, Action onCancel = null, int milliseconds = 500) { var canCancel = source != null; if (!canCancel) { source = new CancellationTokenSource(); // dummy } IProgressDialog dialog = null; return(Task.Run(async() => { // delay var t = 0.0; while (t < milliseconds) { await Task.Delay(TimeSpan.FromMilliseconds(100)); if (task.IsCompleted || task.IsFaulted || (source?.Token.IsCancellationRequested ?? false)) { return await task; } t += 100; } // show dialog = canCancel ? instance.Loading(title, () => { source?.Cancel(true); onCancel?.Invoke(); }, cancelText) : instance.Loading(title); // wait return await task; }, source.Token).ContinueWith(t => { dialog?.Hide(); dialog?.Dispose(); return t.Result; }, source.Token).ContinueWith(t => { if (t.IsCanceled) { return default(T); } if (t.IsFaulted) { // show error UserDialogs.Instance.Alert(t.Exception); return default(T); } return t.Result; }, source.Token)); }
public InsuranceListPopupViewModel(IEventAggregator eventAggregator, IPolicyService policyService, IUserDialogs userDialogs) { _policyService = policyService; _userDialogs = userDialogs; EvlRequestItemSource _request = new EvlRequestItemSource(); SubscriptionToken = eventAggregator.GetEvent <InsuranceEvent>().SubscribeAsync(async(request) => { _request = request; insuranceCancellationTokenSource?.Cancel(); insuranceCancellationTokenSource = new CancellationTokenSource(); using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: insuranceCancellationTokenSource.Cancel)) { await loadInsurances(); } }, keepSubscriberReferenceAlive: true, threadOption: ThreadOption.UIThread); SelectPolicy = new BitDelegateCommand <PolicyItemSource>(async(policy) => { eventAggregator.GetEvent <OpenInsurancePopupEvent>().Publish(new OpenInsurancePopupEvent()); //await NavigationService.NavigateAsync(nameof(EvaluationRequestView), new NavigationParameters { // { "Insurance",policy}, // {nameof(EvlRequestItemSource),_request } //}); }); }
public EvaluationRequestListViewModel(IEvlRequestService evlRequestService, IUserDialogs userDialogs, IPageDialogService dialogService, IEventAggregator eventAggregator) { _evlRequestService = evlRequestService; _userDialogs = userDialogs; _dialogService = dialogService; _eventAggregator = eventAggregator; ShowRequestProgress = new BitDelegateCommand <EvlRequestListItemSource>(async(request) => { await NavigationService.NavigateAsync(nameof(EvlRequestProgressView), new NavigationParameters { { nameof(EvlRequestListItemSource), request } }); }); OpenInquiryBox = new BitDelegateCommand(async() => { eventAggregator.GetEvent <OpenInquiryPopupEvent>().Publish(new OpenInquiryPopupEvent()); }); Inquiry = new BitDelegateCommand(async() => { inquiryCancellationTokenSource?.Cancel(); inquiryCancellationTokenSource = new CancellationTokenSource(); using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: inquiryCancellationTokenSource.Cancel)) { if (string.IsNullOrEmpty(DocumentNumber) || !Requests.Any(r => r.Code == int.Parse(DocumentNumber))) { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.DocumentNumberIsInvalid, ConstantStrings.Ok); DocumentNumber = null; return; } EvlRequestDto requestDto = await evlRequestService.SearchByCode(int.Parse(DocumentNumber)); if (requestDto == null) { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.RequestDosentExist, ConstantStrings.Ok); DocumentNumber = null; return; } else { DocumentNumber = null; eventAggregator.GetEvent <OpenInquiryPopupEvent>().Publish(new OpenInquiryPopupEvent()); INavigationParameters parameter = new NavigationParameters(); parameter.Add(nameof(EvlRequestListItemSource), new EvlRequestListItemSource { Code = requestDto.Code, RequestId = requestDto.Id, RequestTypeName = EnumHelper <EvlRequestType> .GetDisplayValue(requestDto.EvlRequestType) }); await NavigationService.NavigateAsync(nameof(EvlRequestProgressView), parameter); } } }); }
public EvaluationRequestLostDetailViewModel( IUserDialogs userDialogs, ILicenseHelper licenseHelper, ISanaapAppTranslateService translateService, IEvlRequestValidator evlRequestValidator, IInitialDataService initialDataService, IPageDialogService dialogService) { _initialDataService = initialDataService; _userDialogs = userDialogs; _licenseHelper = licenseHelper; GoBack = new BitDelegateCommand(async() => { await NavigationService.GoBackAsync(); }); GoToNextLevel = new BitDelegateCommand(async() => { requestCancellationTokenSource?.Cancel(); requestCancellationTokenSource = new CancellationTokenSource(); using (userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: requestCancellationTokenSource.Cancel)) { if (SelectedCar == null) { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.CarIsNull, ConstantStrings.Ok); return; } if (SelectedAlphabet == null) { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.NumberPlateIsNotValid, ConstantStrings.Ok); return; } Request.LostCarId = SelectedCar.PrmID; LostLicense.Alphabet = SelectedAlphabet.Name; if (licenseHelper.ConvertToPlateNumber(LostLicense, out string licensePlate)) { Request.LostPlateNumber = licensePlate; } else { return; } if (!evlRequestValidator.IsLostDetailValid(Request, out string message)) { await dialogService.DisplayAlertAsync(string.Empty, translateService.Translate(message), ConstantStrings.Ok); return; } await NavigationService.NavigateAsync(nameof(EvaluationRequestDescriptionView), new NavigationParameters { { nameof(Request), Request } }); } }); }
public MainViewModel(IOrderController orderController , IDialogService dialogService , IUserDialogs userArcDialogs , ISellerAuthService loginService , ISellerOrderService sellerOrderService) { this._orderController = orderController; this._loginService = loginService; this._sellerOrderService = sellerOrderService; this._dialogService = dialogService; this._userArcDialogs = userArcDialogs; _userArcDialogs.Loading("Загрузка").Hide(); this.OpenNexStackOrder += HomeViewModel_OpenNexStackOrder; this._sellerOrderService.OnNewPayedOrder += _sellerOrderService_OnNewPayedOrder; IsDelayFive = new NC <bool>(false, (e) => { if (e) { var timeOrder = TimeSpan.Parse(this._sendOrder.Time); this._sendOrder.Time = timeOrder.Add(TimeSpan.FromMinutes(5)).ToString(); } else { var timeOrder = TimeSpan.Parse(this._sendOrder.Time); this._sendOrder.Time = timeOrder.Add(TimeSpan.FromMinutes(-5)).ToString(); } }); }
private async Task SaveProfile() { if (!EmailValidator.EmailIsValid(CurrentUser.Email)) { await CoreMethods.DisplayAlert("Email", "Veuillez entrer une adresse email valide", "OK"); return; } using (_dialogs.Loading("Enregistrement...")) { Settings.CurrentUser = JsonConvert.SerializeObject(CurrentUser); var passwd = await ChangePassword(); if (passwd) { CurrentUser.Password = NewPassword; } if (App.IsConnected()) { await App.UserManager.SaveOrUpdateAsync(CurrentUser.Id, CurrentUser, false); } if (passwd) { NavBackCommand.Execute(null); await Task.Delay(400); MessagingCenter.Send(this, "ShowPasswordMessage"); } } }
public ShowContentViewModel(IODataClient oDataClient, IUserDialogs userDialogs, INewsService newsService) { _oDataClient = oDataClient; _userDialogs = userDialogs; _newsService = newsService; Like = new BitDelegateCommand(async() => { using (_userDialogs.Loading(ConstantStrings.Loading)) { bool likeStatus = Content.YourLike; Content.YourLike = await newsService.LikeNews(Content.NewsID); if (Content.YourLike == false && likeStatus == true) { Content.Likes--; } else if (Content.YourLike == true && likeStatus == false) { Content.Likes++; } } }); ShareCommand = new BitDelegateCommand(async() => { await Share.RequestAsync(new ShareTextRequest { Text = NewsService.StripHTML(Content.Text), Title = Content.Title }); }); }
public override async Task OnNavigatedToAsync(INavigationParameters parameters) { registerCancellationTokenSource?.Cancel(); registerCancellationTokenSource = new CancellationTokenSource(); using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: registerCancellationTokenSource.Cancel)) { Request = parameters.GetValue <EvlRequestItemSource>(nameof(Request)); if (Request.Latitude == 0) { try { CurrentPosition = await Geolocation.GetLocationAsync(); } catch (FeatureNotEnabledException ex) { await _dialogService.DisplayAlertAsync(string.Empty, ConstantStrings.GPSNotEnable, ConstantStrings.Ok); await NavigationService.GoBackAsync(); } } else { CurrentPosition = new Location { Latitude = Request.Latitude, Longitude = Request.Longitude }; } await base.OnNavigatedToAsync(parameters); } }
public override async Task OnNavigatedToAsync(INavigationParameters parameters) { if (parameters.GetNavigationMode() == NavigationMode.New) { using (_userDialogs.Loading(ConstantStrings.Loading)) { Request = parameters.GetValue <EvlRequestItemSource>(nameof(Request)); List <PhotoTypeDto> photos; if (Request.InsuranceType == InsuranceType.Sales) { photos = await _initialDataService.GetSalesPhotos(); } else { photos = await _initialDataService.GetBadanePhotos(); } List <EvlRequestFileItemSource> files = photos.Select(i => new EvlRequestFileItemSource { IsRequired = i.IsRequired, TypeId = i.ID, TypeName = i.Name, Image = ImageSource.FromResource("Sanaap.App.Images.photo.jpg") }).ToList(); Files = new ObservableCollection <EvlRequestFileItemSource>(files); await base.OnNavigatedToAsync(parameters); } } }
private async Task OnLoginCommandAsync() { if (string.IsNullOrWhiteSpace(Email)) { await _userDialogsService.AlertAsync(Strings.EnterEmailMessage); return; } if (string.IsNullOrWhiteSpace(Password)) { await _userDialogsService.AlertAsync(Strings.EnterPasswordMessage); return; } AOResult result; using (_userDialogsService.Loading()) { result = await _authorizationService.LoginAsync(Email, Password); } if (result.IsSuccess) { await _navigationService.NavigateAsync('/' + nameof(NavigationPage) + '/' + nameof(RootView), useModalNavigation : false); } else { await _userDialogsService.AlertAsync(Strings.IncorrectLoginDataMessage); } }
/// <summary> ///отменить заказ /// </summary> public async void OnCancelOrder() { _userArcDialogs.Loading("Загрузка"); var recivedCorrectOrder = JsonConvert.SerializeObject(this._sendOrder.Order); //1 this._orderController.CorrectOrder(this._sendOrder.CustomerName, false, recivedCorrectOrder, "false"); var user = await this._loginService.GetProfile(); //2 this._orderController.ChangeStatusOrder(this._sendOrder.Order.ID.ToString() , StatusOrder.refused.ToString(), false, TimeSpan.Zero, "", false); this.OpenNexStackOrder.Invoke(null, this._sendOrder); _userArcDialogs.Loading("Загрузка").Hide(); }
async private void Loading() { long ret = 0; using (_dialogs.Loading("読込中...")) { // 実際重たい処理をさせてみる //for (long i = 0; i < 1000000000; i++) // ret += i; // ↑これだと処理が終わった後にダイアログが表示される ret = await LoadingProc(); // こうやればダイアログが先に表示される } }
public override async Task OnNavigatedToAsync(INavigationParameters parameters) { inquiryCancellationTokenSource?.Cancel(); inquiryCancellationTokenSource = new CancellationTokenSource(); using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: inquiryCancellationTokenSource.Cancel)) { await loadRequests(); } }
public override async void Start() { using (_userDialogs.Loading("Loading")) { var result = await _api.GetAll(); Info = result.Data; } }
private async Task UpdateAuthorizationAsync(CancellationToken token) { using (_userDialogs.Loading()) { if (!IsAuthorized() && CanUpdateAuthorization()) { await _authorizationService.UpdateSessionAsync(null, token); } } }
public override async Task OnNavigatedToAsync(INavigationParameters parameters) { int newsId; parameters.TryGetValue("NewsId", out newsId); using (_userDialogs.Loading(ConstantStrings.Loading)) { await loadContent(newsId); } }
private async Task InitializeData(string id) { var loading = userDialog.Loading("Loading transaction", show: false); loading.Show(); IsBusy = true; Item = await service.GetTransaction(id); if (Item != null) { id = Item.Id; Description = Item.Description; TransDate = Item.TransDate; Amount = Item.Amount; Currency = Item.Currency; Username = Item.Username; Category = Item.Category; } IsBusy = false; loading.Hide(); }
public ContentListViewModel(IODataClient oDataClient, IUserDialogs userDialogs, INewsService newsService, IInitialDataService initialDataService, IEventAggregator eventAggregator, IPageDialogService dialogService) { _oDataClient = oDataClient; _userDialogs = userDialogs; _newsService = newsService; _initialDataService = initialDataService; ShowContent = new BitDelegateCommand <NewsItemSource>(async(content) => { INavigationParameters parameters = new NavigationParameters(); parameters.Add("NewsId", content.NewsID); await NavigationService.NavigateAsync(nameof(ShowContentView), parameters); }); FilterContent = new BitDelegateCommand(async() => { FilterDto.Month = SelectedMonth?.Number; FilterDto.Year = SelectedYear?.Number; if (FilterDto.Month != null || FilterDto.Year != null) { if (FilterDto.Month == null || FilterDto.Year == null) { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.NewsFilterNotValid, ConstantStrings.Ok); SelectedYear = null; SelectedMonth = null; return; } } contentCancellationTokenSource?.Cancel(); contentCancellationTokenSource = new CancellationTokenSource(); using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: contentCancellationTokenSource.Cancel)) { await loadContents(FilterDto); } eventAggregator.GetEvent <OpenNewsFilterPopupEvent>().Publish(new OpenNewsFilterPopupEvent()); FilterDto = new FilterNewsDto(); SelectedYear = null; SelectedMonth = null; }); OpenFilterPopup = new BitDelegateCommand(async() => { eventAggregator.GetEvent <OpenNewsFilterPopupEvent>().Publish(new OpenNewsFilterPopupEvent()); }); }
public async void DisplayBaggageLocation() { try { using (_udialog.Loading("Tracking...")) { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("bagtag", _params.Bagtag); parameters.Add("pnr", _params.PNR); parameters.Add("lastname", _params.LastName.Trim(' ')); var restService = Mvx.Resolve <IRestService>(); restService.WebMethod = "TrackBagScanPoints"; restService.Parameters = parameters; string returnResponse = await restService.Consume(); TrackResponse trackResponse = JsonConvert.DeserializeObject <TrackResponse>(returnResponse); if (trackResponse.StatusCode == "0") { Application.Current.Properties["token"] = trackResponse.Token; if (trackResponse.ScanPoints != null) { var scanList = new ScanList(); foreach (var item in trackResponse.ScanPoints.ToList()) { scanList.Add(new ScanPoints() { Station = item.Station, Location = item.Location, ScanTime = item.ScanTime.ToString("HH:mm MMM dd, yyyy") }); } var list = new List <ScanList>() { scanList }; ScanPointList = list; } } else { ErrorMessage = trackResponse.Message; } Bagtag = _params.Bagtag; PNR = _params.PNR; LastName = _params.LastName; } } catch (Exception e) { Mvx.Resolve <IUserDialogs>().Toast(e.Message, null); } }
public override async Task OnNavigatedToAsync(INavigationParameters parameters) { contentCancellationTokenSource?.Cancel(); contentCancellationTokenSource = new CancellationTokenSource(); using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: contentCancellationTokenSource.Cancel)) { await loadContents(FilterDto); Months = await _initialDataService.GetMonths(); Years = await _initialDataService.GetYears(); } }
public override async void OnNavigatedTo(INavigationParameters parameters) { base.OnNavigatedTo(parameters); await Task.Yield(); using (_userDialogs.Loading()) { var allNotes = await GetAllNotesAsync(); NotesCollection = new ObservableCollection <Note>(allNotes); } }
public override async Task OnNavigatedToAsync(INavigationParameters parameters) { parameters.TryGetValue(nameof(EvlRequestListItemSource), out EvlRequestListItemSource request); RequestCode = request.Code; progressCancellationTokenSource?.Cancel(); progressCancellationTokenSource = new CancellationTokenSource(); using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: progressCancellationTokenSource.Cancel)) { await loadProgresses(request.Code); } }
public static IProgressDialog Loading(this IUserDialogs userDialogs, string title, out CancellationToken cancellationToken, string cancelText = null, Action <CancellationToken> onCancel = null) { cancelText = cancelText ?? Strings.Cancel; CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMinutes(45)); cancellationToken = cancellationTokenSource.Token; return(userDialogs.Loading(title: title, cancelText: cancelText, maskType: MaskType.Clear, onCancel: () => { cancellationTokenSource.Cancel(); onCancel?.Invoke(cancellationTokenSource.Token); })); }
private async Task RefreshData() { var isLoggedIn = false; try { isLoggedIn = CashApp.Helpers.Settings.IsLoggedIn; } catch (Exception ex) { Debug.WriteLine(ex.Message); return; } if (!CashApp.Helpers.Settings.IsLoggedIn) { await service.Initialize(); var user = await DependencyService.Get <IAuthentication>().LoginAsync(service.MobileService, MobileServiceAuthenticationProvider.Google); if (user == null) { return; } } using (var loading = userDialog.Loading("Loading data")) { IsBusy = true; var result = await service.GetTransactions(); var grouping = new Grouping(); var groupingList = new List <Grouping> { grouping }; Items = new ObservableCollection <Grouping>(groupingList); if (result != null) { var sorted = from record in result orderby record.PeriodSort descending group record by new { record.Year, record.Month, record.Period } into gr select new Grouping(gr.Key.Year, gr.Key.Month, gr.Key.Period, gr); Items = new ObservableCollection <Grouping>(sorted); } IsBusy = false; } shouldRefresh = false; }
public async void DisplayBagList() { try { using (_udialog.Loading("Displaying Bag List...")) { //Dictionary<string, string> parameters = new Dictionary<string, string>(); //parameters.Add("pnr", _params.PNR); //parameters.Add("lastname", _params.LastName); var restService = Mvx.Resolve <IRestService>(); //restService.WebMethod = "GetBagList"; // restService.Parameters = parameters; //string returnResponse = await restService.Consume(); GetBagListReponse bagListResponse = await restService.GetBagList(_params.PNR, _params.LastName.Trim(' ')); //GetBagListReponse bagListResponse = JsonConvert.DeserializeObject<GetBagListReponse>(returnResponse); if (bagListResponse.StatusCode == "0") { Application.Current.Properties["token"] = bagListResponse.Token; if (bagListResponse.Bags != null) { var newList = new ObservableCollection <Bagtag>(); foreach (var item in bagListResponse.Bags.ToList()) { newList.Add(new Bagtag() { Bagtags = item }); } BagList = newList; } } else { ErrorMessage = bagListResponse.Message; } PNR = _params.PNR; LastName = _params.LastName; } } catch (Exception e) { Mvx.Resolve <IUserDialogs>().Toast(e.Message, null); } }
public EvaluationRequestMenuViewModel(IEventAggregator eventAggregator, IPolicyService policyService, IUserDialogs userDialogs, IInitialDataService initialDataService, IPageDialogService dialogService) { _policyService = policyService; _userDialogs = userDialogs; _eventAggregator = eventAggregator; EvlRequestBadane = new BitDelegateCommand(async() => { await NavigationService.NavigateAsync(nameof(EvaluationRequestDetailView), new NavigationParameters { { nameof(InsuranceType), InsuranceType.Badane } }); }); EvlRequestSales = new BitDelegateCommand(async() => { await NavigationService.NavigateAsync(nameof(EvaluationRequestDetailView), new NavigationParameters { { nameof(InsuranceType), InsuranceType.Sales } }); }); #region insurancePopup SelectPolicy = new BitDelegateCommand <PolicyItemSource>(async(policy) => { using (_userDialogs.Loading(ConstantStrings.Loading)) { CustomerDto customer = await initialDataService.GetCurrentUserInfo(); eventAggregator.GetEvent <OpenInsurancePopupEvent>().Publish(new OpenInsurancePopupEvent()); _request.InsurerNo = policy.InsurerNo; _request.InsurerId = policy.InsurerId; _request.CarId = policy.CarId; _request.PlateNumber = policy.PlateNumber; _request.OwnerFirstName = customer.FirstName; _request.OwnerLastName = customer.LastName; await NavigationService.NavigateAsync(nameof(EvaluationRequestDetailView), new NavigationParameters { { "Request", _request }, }); } }); #endregion }
public RegisterPageViewModel(INavigationService navigationService, IUserUsecase userUsecase, IUserDialogs userDialogs) : base(navigationService) { _userUsecase = userUsecase; _userDialogs = userDialogs; Name.SetValidateAttribute(() => Name); RegisterCommand = new[] { Name.ObserveHasErrors, _busyNotifier, } .CombineLatestValuesAreAllFalse() .ObserveOn(SynchronizationContext.Current) .ToReactiveCommand() .WithSubscribe(() => { _registerRequested.OnNext(Unit.Default); _userUsecase.Register(Name.Value); }) .AddTo(_disposables); _registerRequested.SelectMany(_ => Observable.Using(() => { return(new CompositeDisposable() { _busyNotifier.ProcessStart(), _userDialogs.Loading(""), }); }, _ => Observable.Amb( _userUsecase.UserRegistered.Select <User, (User?user, Exception?error)>(user => (user, null)), _userUsecase.ErrorOccurred.Select <Exception, (User?user, Exception?error)>(ex => (null, ex))) .Take(1))) .ObserveOn(SynchronizationContext.Current) .Subscribe(async t => { if (t.user is not null) { await _userDialogs.AlertAsync("登録が完了しました", "確認"); await navigationService.NavigateAsync("/MainPage"); } else { await _userDialogs.AlertAsync("登録に失敗しました", "エラー"); } }) .AddTo(_disposables); }
public LoginViewModel( ISecurityService securityService, ISanaapAppLoginValidator loginValidator, IPageDialogService pageDialogService, ISanaapAppTranslateService translateService, IUserDialogs userDialogs) { Login = new BitDelegateCommand(async() => { registerCancellationTokenSource?.Cancel(); registerCancellationTokenSource = new CancellationTokenSource(); using (userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: registerCancellationTokenSource.Cancel)) { if (!loginValidator.IsValid(NationalCode, Mobile, out string errorMessage)) { await pageDialogService.DisplayAlertAsync("", translateService.Translate(errorMessage), "باشه"); return; } try { await securityService.LoginWithCredentials(NationalCode, Mobile, "SanaapResOwner", "secret"); await NavigationService.NavigateAsync($"/{nameof(NavigationPage)}/{nameof(MainMenuView)}"); } catch (Exception ex) { if (ex.Message.Contains("CustomerCouldNotBeFound")) { await pageDialogService.DisplayAlertAsync("", "کاربری با این مشخصات یافت نشد", "باشه"); } else if (translateService.Translate(ex.GetMessage(), out string translateErrorMessage)) { await pageDialogService.DisplayAlertAsync("", translateErrorMessage, "باشه"); } else { string error = ex.ToString(); throw; } } } }); Register = new BitDelegateCommand(async() => { await NavigationService.NavigateAsync(nameof(RegisterView)); }); }