Exemple #1
0
        public ActionResult SaveNewMovie(int?id)
        {
            if (id == null)
            {
                HttpNotFound();
            }
            else
            {
                var data = _Context.Movie.SingleOrDefault(c => c.Id == id);
                if (data != null)
                {
                    var nc = new ViewmodelMovie()
                    {
                        Movies = data,
                        Genres = _Context.Genres.ToList()
                    };
                    return(View(nc));
                }
                else
                {
                    HttpNotFound();
                }
            }

            return(View());
        }
Exemple #2
0
        public ActionResult SaveNewMovie(ViewmodelMovie VMMovie)
        {
            if (VMMovie.Movies.Id != null)
            {
                if (VMMovie.Movies.Name != null && VMMovie.Movies.GenreId != 0 && VMMovie.Movies.Stock.HasValue)
                {
                    var customeridToUpdate = _Context.Movie.Single(c => c.Id == VMMovie.Movies.Id);

                    customeridToUpdate.Name        = VMMovie.Movies.Name;
                    customeridToUpdate.ReleaseDate = VMMovie.Movies.ReleaseDate;
                    customeridToUpdate.GenreId     = VMMovie.Movies.GenreId;
                    customeridToUpdate.Stock       = VMMovie.Movies.Stock;

                    _Context.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(Content("Please fill all the fields.."));
                }
            }
            else
            {
                return(Content("Please fill all the fields."));
            }
        }