/// <summary> /// Handles the AddPerson event of the Btn control. ///Creates a Person Object and posts it 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_AddPerson(object sender, Windows.UI.Xaml.RoutedEventArgs e) { //Fetching user input string firstName = inp_PersonFirstName.Text; string lastName = inp_PersonLastName.Text; DateTime birthDate = inp_PersonBirthDate.Date.DateTime; string pictureLink = inp_PersonPicture.Text; //TODO: add logic for checking if the user input is following criterias //Creating Person object Person newPerson = new Person() { FirstName = firstName, LastName = lastName, BirthDate = birthDate, Picture = pictureLink }; //Logic for adding person via HttpPost await PersonCalls.PostPerson(newPerson); }
/// <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, }); }