コード例 #1
0
        public async override void OnNavigatedTo(NavigationParameters parameters)
        {
            base.OnNavigatedTo(parameters);

            try
            {
                if (parameters.Any(a => a.Key.Equals("posterId")))
                {
                    Poster = await App.ApiService.GetPoster(parameters.GetValue <int>("posterId"), "bearer " + Settings.AuthToken);

                    PetType = Poster.PetType == 1 ? "Cachorro" : "Gato";
                    State   = Poster.State;

                    foreach (var item in Poster.PetPictures)
                    {
                        byte[] file;
                        try
                        {
                            file = await App.ApiService.Download(item.Url);
                        } catch { continue; }

                        PetImages.Add(new PetPictureItem
                        {
                            Id    = Guid.NewGuid().ToString(),
                            Image = file
                        });
                    }
                    EditPosterCommand.RaiseCanExecuteChanged();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.StackTrace);
            }
        }
コード例 #2
0
        public virtual async void AcceptNavigationParameters(NavigationParameters navigationParameters)
        {
            if (navigationParameters.Any(parameter => parameter.Key == "Result"))
            {
                ResultBuilder = navigationParameters["Result"] as StringBuilder;
            }

            await BuildVariablesAsync();
        }
コード例 #3
0
        public void AcceptNavigationParameters(NavigationParameters navigationParameters)
        {
            if (navigationParameters.Any(parameter => parameter.Key == "Table"))
            {
                var table = navigationParameters["Table"] as DataTable;

                Table = table?.AsDataView();
            }
        }
コード例 #4
0
        public override void AcceptNavigationParameters(NavigationParameters navigationParameters)
        {
            base.AcceptNavigationParameters(navigationParameters);

            if (navigationParameters.Any(parameter => parameter.Key == "Environment"))
            {
                ShowEnvironment = (bool)navigationParameters["Environment"];
            }
        }
コード例 #5
0
        public override void OnNavigatedTo(NavigationParameters parameters)
        {
            //MainMasterPageからの遷移であればインスタンスを保持
            var keyName = typeof(MainMasterPageViewModel).Name;

            if (parameters.Any(x => x.Key.Equals(keyName)))
            {
                _mainViewModel = (MainMasterPageViewModel)parameters[keyName];
                _mainViewModel.IsGestureEnabled.Value = false;
            }
        }
コード例 #6
0
        public override void OnNavigatingTo(NavigationParameters parameters)
        {
            //遷移元MemberIdを取得
            var keyName = StatusListPageViewModel.NAVIGATION_PARAM_MEMBER_ID;

            if (parameters.Any(x => x.Key.Equals(keyName)))
            {
                var memberId = (int)parameters[keyName];
                StatusDetailSource.Value = $"https://hlmanager-32609.firebaseapp.com/#/statusMobile/{memberId}";
            }
        }
コード例 #7
0
        public override void OnNavigatedTo(NavigationParameters parameters)
        {
            if (!parameters.Any())
            {
                return;
            }

            var sender = (string)parameters[AppConstants.Sender];
            var result = (bool)parameters[AppConstants.LoginSuccess] ? "Login successful" : "Login failed";

            ShowDialog($"{sender} says, {result}");

            base.OnNavigatedTo(parameters);
        }
コード例 #8
0
        public async override void OnNavigatedTo(NavigationParameters parameters)
        {
            base.OnNavigatedTo(parameters);

            try
            {
                if (parameters.Any(a => a.Key.Equals("posterId")))
                {
                    Poster = await App.ApiService.GetPoster(parameters.GetValue <int>("posterId"), "bearer " + Settings.AuthToken);

                    ImgCastrated = Poster.Castrated ? "icon_checked.png" : "icon_not_checked.png";
                    ImgDewormed  = Poster.Dewormed ? "icon_checked.png" : "icon_not_checked.png";
                }
            }
            catch (Refit.ApiException ex)
            {
                Debug.WriteLine(ex.StackTrace);
            }
        }
 protected bool AreParametersCorrect(NavigationParameters parameters)
 {
     return(parameters.Any(parameter => parameter.Key == IdKey && parameter.Value is string));
 }
コード例 #10
0
        private async Task LoadPosters(NavigationParameters parameters)
        {
            ShowLoading = true;
            try
            {
                var posters = new List <PosterOutput>();

                Filter filter = null;
                if (parameters.Any(a => a.Key.Equals("filter")))
                {
                    filter = parameters.GetValue <Filter>("filter");
                }

                if (filter != null)
                {
                    posters = await App.ApiService.GetFilteredPosters(filter.City ?? string.Empty,
                                                                      filter.PetType, filter.Castrated, filter.Dewormed, "bearer " + Settings.AuthToken);
                }
                else
                {
                    posters = await App.ApiService.GetPosters("bearer " + Settings.AuthToken);
                }

                if (!posters.Any())
                {
                    HasNoPosters = true;
                    return;
                }

                HasNoPosters = false;
                foreach (var poster in posters)
                {
                    poster.MainPictureUrl = poster.PetPictures.FirstOrDefault()?.Url;
                }

                var posterPageParameters = new NavigationParameters
                {
                    { "posters", posters },
                    { "filter", filter }
                };

                await _navigationService.NavigateAsync($"app:///{nameof(MenuPage)}/NavigationPage/{nameof(PostersPage)}", posterPageParameters);
            }
            catch (Exception ex)
            {
                if (ex is Refit.ApiException)
                {
                    var refitEx = ex as Refit.ApiException;
                    if (refitEx.ReasonPhrase.Equals("Unauthorized"))
                    {
                        await App.MobileService.LogoutAsync();

                        await _navigationService.NavigateAsync($"app:///NavigationPage/{nameof(LoginPage)}");
                    }
                }
                Debug.WriteLine(ex.StackTrace);
            }
            finally
            {
                ShowLoading = false;
            }
        }