public async Task <IActionResult> PutWarrantyOwner([FromRoute] int id, [FromBody] WarrantyOwner warrantyOwner) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != warrantyOwner.WarrantyOwnerId) { return(BadRequest()); } _context.Entry(warrantyOwner).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WarrantyOwnerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostWarrantyOwner([FromBody] WarrantyOwner warrantyOwner) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.WarrantyOwners.Add(warrantyOwner); await _context.SaveChangesAsync(); return(CreatedAtAction("GetWarrantyOwner", new { id = warrantyOwner.WarrantyOwnerId }, warrantyOwner)); }