public async Task <IActionResult> Execute(JObject jObj) { if (jObj == null) { throw new ArgumentNullException(nameof(jObj)); } var parameter = _requestBuilder.GetSearchFeedItems(jObj); var searchResult = await _feedRepository.Search(parameter); _halResponseBuilder.AddLinks(l => l.AddSelf(GetFeedItemsLink())); if (searchResult != null && searchResult.Content != null) { var feedItems = searchResult.Content; foreach (var feedItem in feedItems) { _halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetFeedItem(feedItem))); } double r = (double)searchResult.TotalResults / (double)parameter.Count; var nbPages = Math.Ceiling(r); nbPages = nbPages == 0 ? 1 : nbPages; for (var page = 1; page <= nbPages; page++) { _halResponseBuilder.AddLinks(l => l.AddOtherItem("navigation", new Dtos.Link(GetFeedItemsLink(), page.ToString()))); } } return(new OkObjectResult(_halResponseBuilder.Build())); }