public async Task <IActionResult> PostBMouldKindProperty([FromBody] BMouldKindProperty bMouldKindProperty) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.BMouldKindProperty.Add(bMouldKindProperty); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBMouldKindProperty", new { id = bMouldKindProperty.PptId }, bMouldKindProperty)); }
public async Task <IActionResult> PutBMouldKindProperty([FromRoute] int id, [FromBody] BMouldKindProperty bMouldKindProperty) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != bMouldKindProperty.PptId) { return(BadRequest()); } var item = await _context.BMouldKindProperty.FindAsync(id); if (item == null) { return(NotFound()); } if (item.PptType != bMouldKindProperty.PptType) { var details = _context.BMouldPropertyDetail.Where(e => e.PptId == id); _context.BMouldPropertyDetail.RemoveRange(details); } item.PptName = bMouldKindProperty.PptName; item.PptType = bMouldKindProperty.PptType; item.Description = bMouldKindProperty.Description; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BMouldKindPropertyExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }