Exemple #1
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Planet planet)
        {
            if (ModelState.IsValid)
            {
                _context.Add(planet);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(planet));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("Id,Name,PlanetId")] Hero hero)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hero);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PlanetId"] = new SelectList(_context.Planet, "Id", "Id", hero.PlanetId);
            return(View(hero));
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("Id,Img,Name,SuperName,PlanetId,CategoriaId,Power1,Power2,Power3,Universe,Description,Force")] Hero hero)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hero);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoriaId"] = new SelectList(_context.Categoria, "Id", "Id", hero.CategoriaId);
            ViewData["PlanetId"]    = new SelectList(_context.Planet, "Id", "Id", hero.PlanetId);
            return(View(hero));
        }