public async Task <IActionResult> PostListproduct([FromBody] Listproduct listproduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.ListProduct.Add(listproduct); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (ListproductExists(listproduct.IdList)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetListproduct", new { id = listproduct.IdList }, listproduct)); }
public async Task <IActionResult> PutListproduct([FromRoute] int id, [FromBody] Listproduct listproduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != listproduct.IdList) { return(BadRequest()); } _context.Entry(listproduct).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ListproductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }