public async Task <IActionResult> PutGame([FromRoute] int id, [FromBody] Game game) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != game.Id) { return(BadRequest()); } _context.Entry(game).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GameExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("GenreId,Name,Description")] Genre genre) { if (ModelState.IsValid) { _context.Add(genre); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(genre)); }
public async Task <IActionResult> Create([Bind("DeveloperId,Name,StreetAddress,City,Telephone")] Developer developer) { if (ModelState.IsValid) { _context.Add(developer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(developer)); }
public async Task <IActionResult> Create([Bind("Id,Tite,ReleaseDate,Price,Description,InStockAmount")] Game game) { if (ModelState.IsValid) { _context.Add(game); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(game)); }
public async Task <IActionResult> PostGenre([FromBody] Genre genre) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Genre.Add(genre); await _context.SaveChangesAsync(); return(CreatedAtAction("GetGenre", new { id = genre.GenreId }, genre)); }
public async Task <IActionResult> Create([Bind("Id,Name,Description,MinimumRequirements,Price,DeveloperId,GenreId")] Game game) { if (ModelState.IsValid) { _context.Add(game); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DeveloperId"] = new SelectList(_context.Set <Developer>(), "DeveloperId", "DeveloperId", game.DeveloperId); ViewData["GenreId"] = new SelectList(_context.Set <Genre>(), "GenreId", "Description", game.GenreId); return(View(game)); }