Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("FilmId,GenderId")] MovieGender movieGender)
        {
            if (id != movieGender.FilmId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(movieGender);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieGenderExists(movieGender.FilmId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FilmId"]   = new SelectList(_context.Movies, "Id", "Summary", movieGender.FilmId);
            ViewData["GenderId"] = new SelectList(_context.Genders, "Id", "Description", movieGender.GenderId);
            return(View(movieGender));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("FilmId,GenderId")] MovieGender movieGender)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movieGender);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FilmId"]   = new SelectList(_context.Movies, "Id", "Summary", movieGender.FilmId);
            ViewData["GenderId"] = new SelectList(_context.Genders, "Id", "Description", movieGender.GenderId);
            return(View(movieGender));
        }