Пример #1
0
        private void ListItem_Click(object sender, EventArgs e)
        {
            Program      app          = Program.GetInstance();
            MovieService movieService = app.GetService <MovieService>("movies");

            // Get the clicked item
            ListViewItem item = container.SelectedItems[0];

            if (item == null)
            {
                GuiHelper.ShowError("Geen item geselecteerd");
                return;
            }

            // Find the movie
            int   id    = (int)item.Tag;
            Movie movie = movieService.GetMovieById(id);

            if (movie == null)
            {
                GuiHelper.ShowError("Kon geen film vinden voor dit item");
                return;
            }

            // Show screen
            MovieDetail movieDetail = app.GetScreen <MovieDetail>("movieDetail");

            movieDetail.SetMovie(movie);
            app.ShowScreen(movieDetail);
        }
        private void SaveButton_Click(object sender, EventArgs e)
        {
            Program      app          = Program.GetInstance();
            MovieService movieManager = app.GetService <MovieService>("movies");

            // Upload image
            StorageFile image = StorageHelper.UploadImage(imagePreview.ImageLocation);

            // Create and save movie
            Movie movie = new Movie(nameInput.Text, descriptionInput.Text, genreInput.Text, (int)durationInput.Value, image);

            if (!movieManager.SaveMovie(movie))
            {
                GuiHelper.ShowError(ValidationHelper.GetErrorList(movie));
                return;
            }

            // Redirect to screen
            MovieDetail movieDetail = app.GetScreen <MovieDetail>("movieDetail");

            movieDetail.SetMovie(movie);
            app.ShowScreen(movieDetail);
            GuiHelper.ShowInfo("Film succesvol aangemaakt");
        }