public async Task <ActionResult <Subscription> > PostProduct(Subscription subscription) { _context.Subscription.Add(subscription); await _context.SaveChangesAsync(); return(CreatedAtAction("GetSubscription", new { id = subscription.ID }, subscription)); }
public async Task <IActionResult> PutProduct([FromRoute] int id, [FromBody] Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.Id) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }