public IHttpActionResult GetSearchs(string id) { var searchService = new SearchService(); var result = new SearchModel(); result.PostsSearchResult = new List <GetPostsSearchResult>(); result.CommentsSearchResult = new List <GetCommentsSearchResult>(); var postsSearchResult = searchService.SearchInPosts(new SearchInPostsRequest { Text = id }).PostsSearchResult; var commentsSearchResult = searchService.SearchInComments(new SearchInCommentsRequest { Text = id }).CommentsSearchResult; foreach (var post in postsSearchResult) { var postToAdd = TheModelFactory.CreateGetPostsSearchResult(post); result.PostsSearchResult.Add(postToAdd); } foreach (var commentary in commentsSearchResult) { var commentaryToAdd = TheModelFactory.CreateGetCommentsSearchResult(commentary); result.CommentsSearchResult.Add(commentaryToAdd); } return(Ok(result)); }