public async Task <IActionResult> Execute(JObject jObj) { if (jObj == null) { throw new ArgumentNullException(nameof(jObj)); } var parameter = _requestBuilder.GetSearchAnnouncements(jObj); var searchResult = await _repository.Search(parameter); _halResponseBuilder.AddLinks(l => l.AddSelf(GetProductLink())); if (searchResult != null && searchResult.Content != null) { var products = searchResult.Content; foreach (var product in products) { _enricher.Enrich(_halResponseBuilder, product); } 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(GetProductLink(), page.ToString()))); } } return(new OkObjectResult(_halResponseBuilder.Build())); }
public async Task <IActionResult> Execute(string subject) { if (string.IsNullOrWhiteSpace(subject)) { throw new ArgumentNullException(nameof(subject)); } var announces = await _repository.Search(new SearchClientServicesParameter { Subjects = new [] { subject } }); _halResponseBuilder.AddLinks(l => l.AddSelf(GetAnnouncementLink())); if (announces.TotalResults > 0) { foreach (var announce in announces.Content) { _enricher.Enrich(_halResponseBuilder, announce); } } return(new OkObjectResult(_halResponseBuilder.Build())); }