public IActionResult Put(IssueStateModel model) { IList <IssueState> allStatesForBoard = null; // Make sure that the id and board id match an existing state var stateToUpdate = _context.IssueStates.FirstOrDefault(x => x.Id == model.Id && x.BoardId == model.BoardId); if (stateToUpdate == null) { return(new HttpNotFoundResult()); } if (model.Order != stateToUpdate.Order) { allStatesForBoard = UpdateOrder(model, stateToUpdate, _context); } stateToUpdate.Name = model.Name; _context.SaveChanges(); var wasOrderUpdated = allStatesForBoard != null; if (wasOrderUpdated) { _connectionManager.BroadcastUpdateStates(stateToUpdate.BoardId, Collection(stateToUpdate.BoardId, allStatesForBoard)); } else { _connectionManager.BroadcastUpdateState(Result.ToModel(stateToUpdate)); } return(new NoContentResult()); }