Example #1
0
        /// <summary>When the "Add Genre" button is clicked Post the new genre to the database</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Windows.UI.Xaml.RoutedEventArgs"/> instance containing the event data.</param>
        private async void Btn_AddGenre(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            //Getting the genreName
            string genreName = inp_Genre.Text;

            //If genreName is empty Do not post
            if (genreName.Length < 1)
            {
                return;
            }

            //Creating a genre object
            Genre genre = new Genre()
            {
                GenreName = genreName
            };

            //Logic for adding genre object via HttpPost
            await GenreCalls.PostGenre(genre);
        }
Example #2
0
        /// <summary>Adds the infomation from the chosen Movie to the UI</summary>
        /// <param name="thisT">The current page</param>
        public async void FillContentAsync(MoviePage thisT)
        {
            //Getting a list of all Genres
            ObservableCollection <Genre> allGenres = await GenreCalls.GetGenres();

            ////Getting a list of all People
            ObservableCollection <Person> allPeople = await PersonCalls.GetPeople();


            Genre genreName = new Genre()
            {
                GenreName = "Fetching"
            };

            //Creating strings for a Movie object
            string title     = "title";
            string genre     = "genre";
            string director  = "director";
            string writer    = "writer";
            string movieStar = "movieStar";
            string summary   = "summary";
            string coveruri  = "https://pdfimages.wondershare.com/forms-templates/medium/movie-poster-template-3.png";
            byte   rating    = 0;


            try
            {
                //Adding the name of the genreId with an api call
                genre = GenreCalls.GetGenreNameFromList(allGenres, Convert.ToInt32(MovieContainer.GenreId));
            }
            catch
            {
                //Category will not be displayed with the name
                genre = MovieContainer.GenreId.ToString();
            }
            try
            {
                //finding the name of the director with help of the id from the parameter (API CALL)
                //if "parameters.directorid" == null the convertion to int32 fails
                director = PersonCalls.GetPersonNameFromList(allPeople, Convert.ToInt32(MovieContainer.DirectorId));
            }
            catch
            {
                //person will not be displayed with the name
                director = MovieContainer.DirectorId.ToString();
            }
            try
            {
                //finding the name of the writer with help of the id from the parameter
                //if "parameters.writerid" == null the convertion to int32 fails
                writer = PersonCalls.GetPersonNameFromList(allPeople, Convert.ToInt32(MovieContainer.WriterId));
            }
            catch
            {
                //person will not be displayed with the name
                writer = MovieContainer.WriterId.ToString();
            }
            try
            {
                //finding the name of the actor star with help of the id from the parameter
                //if "parameters.star" == null the convertion to int32 fails and is Catched
                movieStar = PersonCalls.GetPersonNameFromList(allPeople, Convert.ToInt32(MovieContainer.Star));
            }
            catch
            {
                //person will not be displayed with the name
                movieStar = MovieContainer.Star.ToString();
            }

            //self explainatory
            summary  = MovieContainer.Summary;
            coveruri = MovieContainer.CoverImage;
            title    = MovieContainer.Title;

            //converting the rating to a string to be displayed in the bound textblock
            rating = Convert.ToByte(MovieContainer.Rating);

            //defines the width of the yellow fill in the star image located above the cover image
            //there are 5 stars with the width of 68px.
            //since rating is up to 10 i need to divide it by 2. this makes the stars and rating equal.
            //the "starrating.width" fills the stars so that it represents the real value.
            double amountRatingStars = Convert.ToDouble((MovieContainer.Rating * 68) / 2); // rating/2 * 68pixels each star)

            //Clearing the listitems
            ListItems.Clear();

            //Adding a listitem with values specified above
            ListItems.Add(
                new Movie()
            {
                Title            = title,
                GenreName        = genre,
                Genre            = genreName,
                DirectorName     = director,
                WriterName       = writer,
                StarName         = movieStar,
                Summary          = summary,
                CoverImage       = coveruri,
                Rating           = rating, //Rating
                RatingImageWidth = amountRatingStars,
            });
        }
Example #3
0
        /// <summary>Creates collection for all of the genres in the current list</summary>
        public async void GetAllLists()
        {
            //Getting the user owned lists
            ObservableCollection <AllList> userLists = await ListCalls.GetTokenOwnerLists(LoginPage.token);

            //Creating objects that contains the listId's
            AllList toWatchList = new AllList();
            AllList watchedList = new AllList();

            //Adding the listId's to the appropiat list object
            foreach (AllList n in userLists)
            {
                //Adding to ToWatch List object
                if (n.ListName == "ToWatch")
                {
                    toWatchList.ListId   = n.ListId;
                    toWatchList.ListName = n.ListName;
                }
                //Adding to watched List object
                if (n.ListName == "Watched")
                {
                    watchedList.ListId   = n.ListId;
                    watchedList.ListName = n.ListName;
                }
            }

            //Getting all the listItems from the ToWatch List
            ObservableCollection <AllListItems> allTowatchListObjects = await ListItemCalls.GetListItems(toWatchList.ListId);

            //Getting all the listItems from the ToWatch List
            ObservableCollection <AllListItems> allWatchedListObjects = await ListItemCalls.GetListItems(watchedList.ListId);

            //Getting All of the Movies
            allMovies = await MovieCalls.GetMovies();

            //Creating lists for storing allMovie object for the toWatch and watched list
            ObservableCollection <Movie> allToWatchMovies = new ObservableCollection <Movie>();
            ObservableCollection <Movie> allWatchedMovies = new ObservableCollection <Movie>();

            //Comparing the All ListObjects movie id with tall movies (Intensive task that can be optimised)
            foreach (Movie m in allMovies)
            {
                //ToWatch
                foreach (AllListItems toWatchI in allTowatchListObjects)
                {
                    //If the movie exists in the towatchlist add the Movie object to the new list
                    //This is so that the Movie object that contains all of the information can be displayed in the UI
                    if (m.MovieId == toWatchI.MovieId)
                    {
                        //Adding the movie to the new list
                        allToWatchMovies.Add(m);
                    }
                }
                //Watched
                foreach (AllListItems watched in allWatchedListObjects)
                {
                    //See comments on the foreach loop above
                    if (m.MovieId == watched.MovieId)
                    {
                        allWatchedMovies.Add(m);
                    }
                }
            }

            //Creating reference to the stackPanel that should contain the list
            StackPanel stack_toWatch = Stack_listViews;
            StackPanel stack_Watched = Stack_Watched;

            //Creating the stack lists in the ToWatch Tab
            DynamicListViewCreator("All Genres", allToWatchMovies, stack_toWatch);

            //Creating the stack lists in the Watched Tab
            DynamicListViewCreator("All Genres", allWatchedMovies, Stack_Watched);



            //The new lists can now be used to create seperate lists for every genreId that exists in the Movie collection lists

            //Firstly we need all of the Genre objects that excist.
            //Then we can compare all existing genreId's with the ones that exist in the Watched and toWatch lists.
            ObservableCollection <Genre> allGenres = await GenreCalls.GetGenres();

            //Looping through the allGenres list
            foreach (Genre existingGenres in allGenres)
            {
                //Creates a temporary list to store the movie that contain the current genre
                ObservableCollection <Movie> genreListWatched = new ObservableCollection <Movie>();
                foreach (Movie allWatched in allWatchedMovies)
                {
                    //Finding out that if the allWatched contains the genre
                    if (existingGenres.GenreId == allWatched.GenreId)
                    {
                        //Adding movie with same genre to the list
                        genreListWatched.Add(allWatched);
                    }
                }
                //If any movies got added create a new List in the UI
                if (genreListWatched.Count > 0)
                {
                    DynamicListViewCreator(existingGenres.GenreName, genreListWatched, Stack_Watched);
                }

                //Creates a temporary list to store the movie that contain the current genre
                ObservableCollection <Movie> genreListToWatch = new ObservableCollection <Movie>();
                foreach (Movie allToWatch in allToWatchMovies)
                {
                    //Finding out that if the allToWatch contains the genre
                    if (existingGenres.GenreId == allToWatch.GenreId)
                    {
                        //Adding movie with same genre to the list
                        genreListToWatch.Add(allToWatch);
                    }
                }
                //If any movies got added create a new List in the UI
                if (genreListToWatch.Count > 0)
                {
                    DynamicListViewCreator(existingGenres.GenreName, genreListToWatch, stack_toWatch);
                }
                //End of Genre Loop
            }
        }