public async Task <Code> GetLatestCode([FromRoute] Guid deviceId, bool invoke = true) { Device dev = await GetDeviceAsync(deviceId); if (dev == null) { return(null); } Code code = _repository.GetLatest(dev); if (code == null) { return(null); } if (invoke) { await _hubContext.Clients.Group(GetUserName()).InvokeAsync("codeFetched", dev.Name, string.IsNullOrWhiteSpace(code.ActionName) ? code.Action.ToString() : code.ActionName); } return(code); }