コード例 #1
0
        public async Task <SongSearchResponse> FormattedSongSearch(FormattedSongSearchRequest request)
        {
            try
            {
                var result =
                    await _searchClient.PostAsync("FormattedSongSearch", HttpClientHelper.GetJsonData(request));

                return(JsonConvert.DeserializeObject <SongSearchResponse>(await result.Content.ReadAsStringAsync()));
            }
            catch (Exception e)
            {
                return(HttpClientHelper.LogError <SongSearchResponse>(_logger, e,
                                                                      new object[] { request.ArtistName, request.SongName }));
            }
        }
コード例 #2
0
        public async Task <IActionResult> FormattedSongSearch([FromBody] FormattedSongSearchRequest request)
        {
            try
            {
                var searchResults = await _solrService.Search(request.ArtistName, request.SongName);

                return(new JsonResult(new SongSearchResponse
                {
                    SearchResults = searchResults
                }));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Error in FormattedSongSearch");
                return(BadRequest());
            }
        }