public async Task <IActionResult> PutCustomProducts([FromRoute] int id, [FromBody] CustomProducts customProducts) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customProducts.Id) { return(BadRequest()); } _context.Entry(customProducts).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomProductsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostCustomProducts([FromBody] CustomProducts customProducts) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.CustomProducts.Add(customProducts); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCustomProducts", new { id = customProducts.Id }, customProducts)); }