public CardItemConcert(MainMenuxaml win, Concert concert) { this.win = win; InitializeComponent(); Uri urislide1 = new Uri(concert.Image_Main, UriKind.RelativeOrAbsolute); this.MainImageConcert.Source = BitmapFrame.Create(urislide1); this.EventNameConcert.Text = concert.Name ?? ""; foreach (string s in FilmHandler.GetListOfGenres(concert.Genre)) { if (s == FilmHandler.GetListOfGenres(concert.Genre).Last()) { this.GenreConcert.Text += s; break; } this.GenreConcert.Text += s + ", "; } if (concert.Address != null) { if (!concert.Address.Equals("")) { if (concert.Address[0] == ' ') { concert.Address = concert.Address.Remove(0, 1); } } this.PlaceCocert.Text = concert.Address + "\n"; } if (concert.Event_Date != null && !concert.Event_Date.Equals("")) { this.TimetableConcert.Text = concert.Event_Date; } this.concert = concert; }
public void GetRightFilmTitle() { HttpClient client = new HttpClient(); FilmDeserializer filmDeserializer = new FilmDeserializer(); FilmHandler filmHandler = new FilmHandler(client, filmDeserializer); Film film = filmHandler.Handle(HttpMethod.Get, "https://ghibliapi.herokuapp.com/films/578ae244-7750-4d9f-867b-f3cd3d6fecf4", null, null); Assert.AreEqual("The Tale of the Princess Kaguya", film.title, "Wrong title"); }
static void UI(HttpClient client) { while (true) { Console.WriteLine("Type number to choose command:"); Console.WriteLine("1. Show all films id and title"); Console.WriteLine("2. Show film by id"); Console.WriteLine("3. Show all people id and name"); Console.WriteLine("4. Show people by id"); Console.WriteLine("5. End program"); var command = Console.ReadLine(); switch (command) { case "1": FilmsDeserializer filmsParser = new FilmsDeserializer(); FilmsHandler filmsHandler = new FilmsHandler(client, filmsParser); WriteAllFilmsIdAndTitle(filmsHandler.Handle(HttpMethod.Get, GHIBLI_SITE + "films", null, null)); break; case "2": Console.WriteLine("Enter film id:"); var filmId = Console.ReadLine(); FilmDeserializer filmParser = new FilmDeserializer(); FilmHandler filmHandler = new FilmHandler(client, filmParser); filmHandler.Handle(HttpMethod.Get, $"{GHIBLI_SITE}films/{filmId}", null, null).WriteFilm(client); break; case "3": AllPeopleDeserializer allPeopleDeserializer = new AllPeopleDeserializer(); AllPeopleHandler allPeopleHandler = new AllPeopleHandler(client, allPeopleDeserializer); WriteAllPeopleIdAndName(allPeopleHandler.Handle(HttpMethod.Get, GHIBLI_SITE + "people", null, null)); break; case "4": Console.WriteLine("Enter people id:"); var peopleId = Console.ReadLine(); PeopleDeserializer peopleDeserializer = new PeopleDeserializer(); PeopleHandler peopleHandler = new PeopleHandler(client, peopleDeserializer); peopleHandler.Handle(HttpMethod.Get, $"{GHIBLI_SITE}people/{peopleId}", null, null).WritePeople(); break; case "5": return; default: Console.WriteLine("Wrong option! Try again."); break; } Console.WriteLine(); } }
public CardItemMoreInfo(MainMenuxaml win, Film film) { this.win = win; InitializeComponent(); Uri urislide1 = new Uri(film.Image_Main, UriKind.RelativeOrAbsolute); this.CardInfoMainImg.Source = BitmapFrame.Create(urislide1); if (film.Images != "") { foreach (string s in FilmHandler.GetListOfImages(film.Images)) { Uri urislide = new Uri(s, UriKind.RelativeOrAbsolute); Image image = new Image { Source = BitmapFrame.Create(urislide), Margin = new Thickness(0, 3, 7, 3), Height = 200, Focusable = true }; this.Images.Children.Add(image); } } this.EventNameCardMoreInfo.Text = film.Name; List <string> list = FilmHandler.GetListOfGenres(film.Genre); foreach (string s in list) { if (s == list.Last()) { this.GenresCardMoreInfo.Text += s; break; } this.GenresCardMoreInfo.Text += s + ", "; } if (film.Country != null) { if (!film.Country.Equals("")) { if (film.Country[0] == ' ') { film.Country = film.Country.Remove(0, 1); } } this.YearCardMoreInfo.Text = film.Year; } this.CountryCardMoreInfo.Text = film.Country; this.DescriptionCardMoreInfo.Text = film.Info; this.BoxOfficeCardMoreInfo.Text = film.Date; this.RatingCardMoreInfo.Text = film.Rating; this.TimeCardMoreInfo.Text = film.Duration; }
public CardItem(MainWindow mwin, MainMenuxaml win, Film film) { this.mainWindow = mwin; this.win = win; InitializeComponent(); Uri urislide1 = new Uri(film.Image_Main, UriKind.RelativeOrAbsolute); this.MainImage.Source = BitmapFrame.Create(urislide1); this.EventName.Text = film.Name; if (!film.Genre.Equals("")) { foreach (string s in FilmHandler.GetListOfGenres(film.Genre)) { if (s == FilmHandler.GetListOfGenres(film.Genre).Last()) { this.Genre.Text += s; break; } this.Genre.Text += s + ", "; } } else { this.Genre.Visibility = Visibility.Collapsed; } if (!film.Country.Equals("")) { if (film.Country[0] == ' ') { film.Country = film.Country.Remove(0, 1); } this.CountryAndYear.Text = film.Country + " " + film.Year; } else { this.CountryAndYear.Visibility = Visibility.Collapsed; } if (!film.Date.Equals("")) { this.BoxOffice.Text = film.Date; } else { this.BoxOffice.Visibility = Visibility.Collapsed; } this.film = film; }
private static void ReceiveCallback(IAsyncResult ar) { try { if (TypeOfTheInfo == TypeOfInfo.User) { ar.AsyncWaitHandle.WaitOne(2000); } if (TypeOfTheInfo == TypeOfInfo.Comment) { ar.AsyncWaitHandle.WaitOne(2000); } StateObject state = (StateObject)ar.AsyncState; Socket client = state.workSocket; client.EndReceive(ar); switch (TypeOfTheInfo) { case TypeOfInfo.Films: { films = FilmHandler.ConvertByteArrayToFilmList(state.buffer); break; } case TypeOfInfo.Cinemas: { cinemas = CinemaHandler.ConvertByteArrayToCinemaList(state.buffer); break; } case TypeOfInfo.Users: { users = UserHandler.ConvertByteArrayToUserList(state.buffer); break; } case TypeOfInfo.User: { flagUser = false; break; } case TypeOfInfo.Favourites: { favourites = FavouritesHandler.ConvertByteArrayToFavouritesList(state.buffer); break; } case TypeOfInfo.Concerts: { concerts = ConcertHandler.ConvertByteArrayToConcertList(state.buffer); break; } case TypeOfInfo.Exhibitions: { exhibitions = ExhibitionHandler.ConvertByteArrayToExhibitionList(state.buffer); break; } case TypeOfInfo.Comments: { comments = CommentHandler.ConvertByteArrayToCommentList(state.buffer); break; } case TypeOfInfo.Favourite: { flagFavourite = false; break; } case TypeOfInfo.Comment: { flagComment = false; break; } default: { break; } } receiveDone.Set(); } catch (Exception ex) { MessageBox.Show(ex.Message); Application application = Application.Current; application.Shutdown(); } }