Esempio n. 1
0
        private void EditMovie(int id, Movie movie)
        {
            _movies.Update(id, movie);
            RefreshUI();
            //if (String.IsNullOrEmpty(error))
            //{
            //   RefreshUI();
            //  return;
            // };

            /*for (var index = 0; index<_movies.Length; ++index)
             * {
             *  // Array element access ::= V{int}
             *  //if (_movies[index] != null && _movies[index].Id == id )
             *  if (_movies[index]?.Id == id) // null conditional ?. if instance != null, access the member otherwise skip
             *  {
             *      //Just because we are doing this in memory (reference type)
             *      movie.Id = id;
             *      _movies[index] = movie;   // Movie is a ref type thus movie and _movies[index] reference the same instance
             *      return;
             *      // Add movie to array
             *  }
             * };*/

            //MessageBox.Show(this, /*"Cannot find movie"*/error, "Edit Movie", MessageBoxButtons.OK);
        }
Esempio n. 2
0
        public ActionResult Edit(MovieViewModel model)

        {
            try

            {
                if (ModelState.IsValid)

                {
                    var movie = model.ToDomain();



                    movie = _database.Update(movie);



                    return(RedirectToAction("List"));
                }
                ;
            } catch (Exception e)

            {
                ModelState.AddModelError("", e.Message);
            };



            return(View(model));
        }
Esempio n. 3
0
        public IActionResult Edit(int id, MovieEditViewModel ViewModel)
        {
            Movie movie = new Movie()
            {
                Title       = ViewModel.Title,
                Description = ViewModel.Description,
                ReleaseDate = ViewModel.ReleaseDate,
                Genre       = ViewModel.Genre
            };

            _movieDatabase.Update(id, movie);
            return(RedirectToAction("Detail", new { Id = id }));
        }
Esempio n. 4
0
        private void EditMovie(Movie movie)
        {
            var child = new MovieDetailForm();

            child.Movie = movie;
            if (child.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            //Save Movie
            _database.Update(child.Movie);
            RefreshList();
        }
Esempio n. 5
0
        public IActionResult Edit(int id, MovieEditViewModel movie)
        {
            if (!TryValidateModel(movie))
            {
                return(View(movie));
            }

            _movieDatabase.Update(id, new Movie()
            {
                Title       = movie.Title,
                Genre       = movie.Genre,
                Description = movie.Description,
                ReleaseDate = movie.ReleaseDate
            });

            return(RedirectToAction("Detail", new { Id = id }));
        }
        public IActionResult Edit([FromRoute] int id, [FromForm] EditMovieViewModel movie)
        {
            if (!TryValidateModel(movie))
            {
                return(View());
            }

            _movieDatabase.Update(id, new Movie
            {
                Title       = movie.Title,
                Description = movie.Description,
                Genre       = movie.Genre,
                Rating      = movie.Rating,
                ReleaseDate = movie.ReleaseDate,
            });

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 7
0
        private void OnMovieEdit(object sender, EventArgs e)
        {
            var movie = GetSelectedMovie();

            if (movie == null)
            {
                return;
            }

            var form = new MovieForm();

            form.Movie = movie;

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                _movies.Update(movie.Id, form.Movie);
                UpdateUI();
            }
        }
Esempio n. 8
0
        public IActionResult Edit(int id, MovieEditViewModel vm)
        {
            if (!TryValidateModel(vm))
            {
                return(View(vm));
            }

            Movie domainMovie = new Movie()
            {
                Id          = id,
                Title       = vm.Title,
                Description = vm.Description,
                Genre       = vm.Genre,
                Releasedate = vm.Releasedate
            };

            _movieDatabase.Update(id, domainMovie);

            return(RedirectToAction("Detail", new { Id = id }));
        }
Esempio n. 9
0
        public ActionResult Edit(MovieViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var product = model.ToDomain();

                    _database.Update(product);

                    return(RedirectToAction(nameof(List)));
                }
                ;
            } catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            };

            return(View(model));
        }
Esempio n. 10
0
        public IActionResult Edit(int id, MovieEditViewModel model)
        {
            if (!TryValidateModel(model))
            {
                return(View(model));
            }

            Movie movieToUpdate = new Movie()
            {
                Id          = id,
                Title       = model.Title,
                Description = model.Description,
                Genre       = model.Genre,
                ReleaseDate = model.ReleaseDate,
                Rating      = model.Rating
            };

            _movieDatabase.Update(id, movieToUpdate);

            return(RedirectToAction("Details", new { Id = id }));
        }
Esempio n. 11
0
 private void EditMovie(int id, Movie movie)
 {
     _movies.Update(id, movie);
     RefreshUI();
     //var error = _movies.Update(id, movie);
     //if (String.IsNullOrEmpty(error))
     //{
     //    RefreshUI();
     //    return;
     //};
     //for (var index = 0; index < _movies.Length; ++index)
     //{
     //    if (_movies[index]?.Id == id) //null conditional ?. if instance != null acess the member
     //    {
     //        //Just because we are doing this in memory
     //        movie.Id = id;
     //        _movies[index] = movie;
     //        return;
     //    };
     //};
     // MessageBox.Show(this, error, "Edit Movie", MessageBoxButtons.OK);
 }