public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Genres,DirectorId,ReleaseYear")] Movie movie)
        {
            if (id != movie.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(movie);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieExists(movie.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DirectorId"] = new SelectList(_context.Director, "Id", "Id", movie.DirectorId);
            return(View(movie));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Website")] Director director)
        {
            if (id != director.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(director);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DirectorExists(director.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(director));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,ActorId,MovieId")] MovieCastAssignment movieCastAssignment)
        {
            if (id != movieCastAssignment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(movieCastAssignment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieCastAssignmentExists(movieCastAssignment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ActorId"] = new SelectList(_context.Actor, "Id", "Id", movieCastAssignment.ActorId);
            ViewData["MovieId"] = new SelectList(_context.Movie, "Id", "Id", movieCastAssignment.MovieId);
            return(View(movieCastAssignment));
        }