public async Task <IActionResult> PutDoorPrize([FromRoute] long id, [FromForm] DoorPrize doorPrize) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != doorPrize.Id) { return(BadRequest()); } _context.Entry(doorPrize).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DoorPrizeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostDoorPrize([FromBody] DoorPrize doorPrize) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.DoorPrize.Add(doorPrize); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDoorPrize", new { id = doorPrize.Id }, doorPrize)); }