public IActionResult PerformAction([FromBody] ComponentDto component) { var comp = _repository.Component.GetComponentById(component.id); var cat = _repository.Category.GetCategoryById(comp.Categoryid); ArduinoConnector connection = new ArduinoConnector(); bool succes = false; succes = connection.Send_Data(comp, cat); if (succes) { comp.value = comp.value == 0?1:0; _repository.Component.UpdateComponent(comp); _repository.Save(); return(Ok("action succesfull")); } return(StatusCode(500, "Internal server error")); }