示例#1
0
        public async Task <IActionResult> albums(int artistId, [FromQuery(Name = "takeCount")] int takeCount)
        {
            try
            {
                var isExists = await _artistService.isExists(x => x.Id == artistId);

                if (isExists)
                {
                    if (artistId > 0)
                    {
                        if (takeCount > 0)
                        {
                            return(Ok(await _artistService.GetLatest(artistId, takeCount)));
                        }
                        else
                        {
                            return(Ok(await _artistService.GetAlbums(artistId)));
                        }
                    }
                    else
                    {
                        return(BadRequest());
                    }
                }
                else
                {
                    return(CustomNotFound(artistId));
                }
            }
            catch (Exception exception)
            {
                return(ErrorInternal(exception, $"{ControllerContext.ActionDescriptor.DisplayName} Exception Message : {exception.Message} - {exception.InnerException}"));
            }
        }
示例#2
0
        public void GetAlbumsListTest()
        {
            AddArtistTest();

            using (var repository = _factory.GetAlbumRepository())
            {
                repository.AddOrUpdate(new Album {
                    Name = "Some album"
                });
                repository.SaveChanges();
            }

            Assert.IsNotNull(_artistService.GetAlbums(1));

            Mock.Get(_factory.GetArtistRepository())
            .Verify(m => m.GetById(It.IsAny <int>()), Times.Once);

            Mock.Get(_factory.GetAlbumRepository())
            .Verify(m => m.GetAll(It.IsAny <Expression <Func <Album, bool> > >(),
                                  It.IsAny <Expression <Func <Album, BaseEntity> >[]>()), Times.Once);
        }
 public async Task <List <Album> > GetAlbums(int id, [FromQuery] AlbumSearchRequest request)
 {
     return(await _service.GetAlbums(id, request));
 }