コード例 #1
0
 private Release GetReleaseFromSearch(ReleaseSearch releaseSearch, string artistName)
 {
     return(releaseSearch.Results != null
                         ? releaseSearch.Results.FirstOrDefault(x => x.Release.Artist.Name == artistName).Release
            ?? releaseSearch.Results.FirstOrDefault().Release
                         : null);
 }
コード例 #2
0
        public ReleaseDetailController()
        {
            IKernel kernal         = new StandardKernel(new BindModule());
            var     amazonItemRepo = kernal.Get <IAmazonItemRepository>();
            var     itunesItemRepo = kernal.Get <IItunesItemRepository>();

            _releaseSearch = new ReleaseSearch(amazonItemRepo, itunesItemRepo);
        }
コード例 #3
0
        public void Can_hit_endpoint_with_paging()
        {
            ReleaseSearch artistBrowse = Api <ReleaseSearch> .Create
                                         .WithParameter("q", "no surprises")
                                         .WithParameter("page", "2")
                                         .WithParameter("pageSize", "20")
                                         .Please();

            Assert.That(artistBrowse, Is.Not.Null);
            Assert.That(artistBrowse.Page, Is.EqualTo(2));
            Assert.That(artistBrowse.PageSize, Is.EqualTo(20));
        }
コード例 #4
0
        public void Can_hit_endpoint()
        {
            ReleaseSearch release = Api <ReleaseSearch> .Create
                                    .WithParameter("q", "no surprises")
                                    .WithParameter("type", ReleaseType.Single.ToString())
                                    .WithParameter("country", "GB")
                                    .Please();

            Assert.That(release, Is.Not.Null);
            Assert.That(release.Results.Count, Is.GreaterThan(0));
            Assert.That(release.Results.FirstOrDefault().Release.Type, Is.EqualTo(ReleaseType.Single));
        }
コード例 #5
0
        public Release GetRelease(string artistName, string releaseTitle)
        {
            ReleaseSearch releaseSearch = GetReleaseTitleMatches(releaseTitle);

            if (releaseSearch != null)
            {
                var releaseFromSearch = GetReleaseFromSearch(releaseSearch, artistName);
                if (releaseFromSearch != null)
                {
                    releaseFromSearch.Image = GenerateLargePackshotImage(releaseFromSearch.Image);
                }

                return(releaseFromSearch);
            }
            return(null);
        }
コード例 #6
0
        public IActionResult Get(string asin)
        {
            var releaseSearch = new ReleaseSearch(_amazonItemRepo, _itunesItemRepo);
            MusicReleaseCollection musicReleaseDetailModel = null;

            try
            {
                musicReleaseDetailModel = releaseSearch.GetDetails(asin);
            }
            catch (WebException ex)
            {
                return(StatusCode(500, ex.Message));
            }

            if (musicReleaseDetailModel != null)
            {
                return(Ok(musicReleaseDetailModel));
            }
            else
            {
                return(StatusCode(500));
            }
        }