public async Task <IActionResult> Edit(int id, [Bind("MovieId,PlatformId")] MoviePlatform moviePlatform)
        {
            if (id != moviePlatform.MovieId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(moviePlatform);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MoviePlatformExists(moviePlatform.MovieId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MovieId"]    = new SelectList(_context.Movies, "Id", "Title", moviePlatform.MovieId);
            ViewData["PlatformId"] = new SelectList(_context.Platforms, "Id", "Title", moviePlatform.PlatformId);
            return(View(moviePlatform));
        }
示例#2
0
        public IActionResult BindMovie(long MovieId, int PlatformId)
        {
            MoviePlatform moviePlatform = new MoviePlatform();

            moviePlatform.MovieId    = MovieId;
            moviePlatform.PlatformId = PlatformId;
            db.MoviePlatforms.Add(moviePlatform);
            db.SaveChanges();
            return(Ok(new ResWrapper {
                Status = "OK", args = moviePlatform
            }));
        }
        public async Task <IActionResult> Create([Bind("MovieId,PlatformId")] MoviePlatform moviePlatform)
        {
            if (ModelState.IsValid)
            {
                _context.Add(moviePlatform);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MovieId"]    = new SelectList(_context.Movies, "Id", "Title", moviePlatform.MovieId);
            ViewData["PlatformId"] = new SelectList(_context.Platforms, "Id", "Title", moviePlatform.PlatformId);
            return(View(moviePlatform));
        }