public async Task <IActionResult> PutCreditCard([FromRoute] int id, [FromBody] CreditCard creditCard) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != creditCard.CardID) { return(BadRequest()); } _context.Entry(creditCard).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CreditCardExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTopping([FromRoute] int id, [FromBody] Topping topping) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != topping.ToppingID) { return(BadRequest()); } _context.Entry(topping).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ToppingExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }