//Edit Machine public async Task <bool> UpdateMachineById([FromUri] int id, [FromBody] MachineEdit model) { Machine machine = _context .Machines .Single(m => m.MachineId == id); machine.MachineName = model.MachineName; machine.AreaId = model.AreaId; return(await _context.SaveChangesAsync() == 1); }
public async Task <IHttpActionResult> UpdateMachine([FromUri] int id, [FromBody] MachineEdit model) { //check if model is valid if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //instantiate service MachineService service = CreateMachineService(); //check if updated if (await service.UpdateMachineById(id, model) == false) { return(InternalServerError()); } return(Ok()); //200 }