public async Task <IActionResult> PutCard([FromRoute] int id, [FromBody] Card card) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != card.Id) { return(BadRequest()); } _context.Entry(card).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CardExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostCardCollection([FromBody] CardCollection cardCollection) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.CardCollection.Add(cardCollection); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCardCollection", new { id = cardCollection.Id }, cardCollection)); }