Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("HeroID,NameHero,HitRangeHeroID")] HeroLol heroLol)
        {
            if (id != heroLol.HeroID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(heroLol);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HeroLolExists(heroLol.HeroID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HitRangeHeroID"] = new SelectList(_context.HitRangeHeros, "HitRangeHeroID", "HitRangeHeroID", heroLol.HitRangeHeroID);
            return(View(heroLol));
        }
        public async Task <ActionResult <HeroLol> > PostHeroLol(HeroLol heroLol)
        {
            _context.HeroLols.Add(heroLol);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetHeroLol), new { id = heroLol.HeroID }, heroLol));
        }
        public async Task <IActionResult> PutHeroLol(int id, HeroLol heroLol)
        {
            if (id != heroLol.HeroID)
            {
                return(BadRequest());
            }

            _context.Entry(heroLol).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HeroLolExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("HeroID,NameHero,HitRangeHeroID")] HeroLol heroLol)
        {
            if (ModelState.IsValid)
            {
                _context.Add(heroLol);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HitRangeHeroID"] = new SelectList(_context.HitRangeHeros, "HitRangeHeroID", "HitRangeHeroID", heroLol.HitRangeHeroID);
            return(View(heroLol));
        }