public IActionResult Create([FromBody] CartMhe cartmhe) { if (cartmhe == null) { return(BadRequest()); } repo.Add(cartmhe); return(CreatedAtRoute("GetCartMHE", new { id = cartmhe.CartMheid }, cartmhe)); }
// Update an CartMHE public void Update(CartMhe cartmhe) { var cartmheToUpdate = _context.CartMhe.Single(o => o.CartMheid == cartmhe.CartMheid); if (cartmheToUpdate != null) { cartmheToUpdate.DeadBattery = cartmhe.DeadBattery; cartmheToUpdate.BrokenWheels = cartmhe.BrokenWheels; cartmheToUpdate.TurntableMalfunction = cartmhe.TurntableMalfunction; cartmheToUpdate.Other = cartmhe.Other; cartmheToUpdate.CartMhedate = cartmhe.CartMhedate; _context.SaveChanges(); } }
public IActionResult Update(int id, [FromBody] CartMhe cartmhe) { if (cartmhe == null || cartmhe.CartMheid != id) { return(BadRequest()); } var cartmheItem = repo.Find(id); if (cartmheItem == null) { return(NotFound()); } repo.Update(cartmhe); return(new NoContentResult()); }
// Add an CartMHE public void Add(CartMhe cartmhe) { _context.CartMhe.Add(cartmhe); _context.SaveChanges(); }