/// <summary>
            ///     Eine Page auf den Stack pushen
            /// </summary>
            /// <param name="nextPage">die Page</param>
            /// <returns>Ergebnis</returns>
            public async Task <object> PushPage(object nextPage)
            {
                if (MasterDetailPage != null)
                {
                    MasterDetailPage.IsPresented = false;
                }

                var vm   = (nextPage as IView).GetViewModel();
                var page = nextPage as Page;

                var navPage = NavPage;

                await navPage.PushAsync(page, true);

                var handler = new PopHandler(navPage, page);

                _popHandlers.Add(handler);
                var   task = handler.WaitTillItPops();
                await task;

                if (!handler.HasBeenCanceled)
                {
                    return(vm.ViewResult);
                }
                return(null);
            }
Exemplo n.º 2
0
        private async Task SubmitReview()
        {
            if (!ValidateEmpty())
            {
                await Application.Current.MainPage.DisplayAlert("Error", "Please fill out the required fields (Review Text, Rating)", "OK");

                return;
            }
            bool v = await ValidateReviewExists();

            if (!v)
            {
                await Application.Current.MainPage.DisplayAlert("Error", "You can't review the same album more than once!", "OK");
            }
            else
            {
                ReviewUpsertRequest request = new ReviewUpsertRequest()
                {
                    AlbumId    = ThisAlbumId,
                    Rating     = int.Parse(Rating),
                    ReviewText = ReviewText,
                    UserId     = APIService.loggedProfile.UserId
                };
                SetFavProperties();
                request.FavouriteSongs      = FavTracks;
                request.LeastFavouriteSongs = LeastFavTracks;
                var inserted = await _reviewService.Insert <Review>(request);

                await _postSerivce.Insert <Post>(new PostUpsertRequest()
                {
                    AdminName       = APIService.loggedProfile.Username,
                    ArtistRelatedId = LoadedAlbum.ArtistId,
                    IsGlobal        = false,
                    Opphoto         = APIService.loggedProfile.UserPhoto,
                    PostDateTime    = DateTime.Now,
                    PostPhoto       = LoadedAlbum.AlbumPhoto,
                    PostText        = ReviewText + "\n \n " + "Favorite tracks: " + FavTracks + "\n \n " + "Least favorite tracks: " + LeastFavTracks + "\n \n" +
                                      "Rating: " + Rating,
                    PostTitle = "Album Review: " +
                                LoadedAlbum.AlbumName,
                    ReviewRelatedId = inserted.ReviewId,
                    UserRelatedId   = APIService.loggedProfile.UserId
                });

                await GlobalMethods.GenerateRating(ThisAlbumId);

                await Application.Current.MainPage.DisplayAlert("Success", "Review successfully added! You will now be redirected to the album page.", "OK");

                PopHandler?.Invoke(this, null);
            }
        }
Exemplo n.º 3
0
        public void StaticDelegate()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            fob.DelegateType = typeof(PopHandler);
            fob.TargetType   = typeof(OneThirstyDude);
            fob.MethodName   = "StaticHandlePop";
            fob.IsSingleton  = false;
            fob.AfterPropertiesSet();
            PopHandler popper = (PopHandler)fob.GetObject();

            Assert.IsNotNull(popper);
            Assert.AreEqual(fob.MethodName, popper.Method.Name);
        }
Exemplo n.º 4
0
        public void InstancePrototypeDelegate()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            fob.IsSingleton  = false;
            fob.DelegateType = typeof(PopHandler);
            OneThirstyDude dude = new OneThirstyDude();

            fob.TargetObject = dude;
            fob.MethodName   = "HandlePop";
            fob.IsSingleton  = false;
            fob.AfterPropertiesSet();
            PopHandler one = (PopHandler)fob.GetObject();
            PopHandler two = (PopHandler)fob.GetObject();

            Assert.IsFalse(ReferenceEquals(one, two));
        }
Exemplo n.º 5
0
        public void InstanceSingletonDelegate()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            fob.DelegateType = typeof(PopHandler);
            OneThirstyDude dude = new OneThirstyDude();

            fob.TargetObject = dude;
            fob.MethodName   = "HandlePop";
            fob.AfterPropertiesSet();
            PopHandler popper = (PopHandler)fob.GetObject();

            Assert.IsNotNull(popper);
            Assert.AreEqual(fob.MethodName, popper.Method.Name);
            string soda = "The Drink Of Champions";

            popper(this, soda);
            Assert.AreEqual(soda, dude.Soda);
            PopHandler other = (PopHandler)fob.GetObject();

            Assert.IsTrue(ReferenceEquals(popper, other));
        }