public async Task <IActionResult> PostBMachineKindProperty([FromBody] BMachineKindProperty bMachineKindProperty) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.BMachineKindProperty.Add(bMachineKindProperty); await _context.SaveChangesAsync(); return(CreatedAtAction("GetBMachineKindProperty", new { id = bMachineKindProperty.PptId }, bMachineKindProperty)); }
public async Task <IActionResult> PutBMachineKindProperty([FromRoute] int id, [FromBody] BMachineKindProperty bMachineKindProperty) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != bMachineKindProperty.PptId) { return(BadRequest()); } var item = await _context.BMachineKindProperty.FindAsync(id); if (item == null) { return(NotFound()); } if (item.PptType != bMachineKindProperty.PptType) { var details = _context.BMachinePropertyDetail.Where(e => e.PptId == id); _context.BMachinePropertyDetail.RemoveRange(details); } item.PptName = bMachineKindProperty.PptName; item.PptType = bMachineKindProperty.PptType; item.Description = bMachineKindProperty.Description; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BMachineKindPropertyExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }