public byte[] AddQuery(byte[] data) { SearchQuery query = JsonConvert.DeserializeObject <SearchQuery>( Encoding.UTF8.GetString(data)); SearchQuery existingQuery = _repo.GetQuery(query.Text); if (existingQuery == null) { _repo.AddQueryAsync(query).Wait(); } return(Encoding.UTF8.GetBytes( JsonConvert.SerializeObject(query))); }