public GetAllAlbumsByFilterResponse GetAllAlbumsByFilter(GetAllAlbumsByFilterRequest request) { GetAllAlbumsByFilterResponse response = new GetAllAlbumsByFilterResponse(); response.ListAlbums = new List <AlbumsApp>(); var responseService = _albumService.GetAll(); response.ListAlbums = _mapper.Map <List <AlbumsApp> >(responseService); string generalSettings = _configuration.GetSection("GeneralSettings").GetSection("PageSize").Value; int pageSize = String.IsNullOrEmpty(generalSettings) ? 10 : Convert.ToInt32(generalSettings); response.totalItens = response.ListAlbums.Count(); response.PageSize = pageSize; response.PageNumber = request.PageNumber; response.ListAlbums = OrderList(response.ListAlbums, request.SortBy, request.IsAsc); response.ListAlbums = response.ListAlbums .Skip((request.PageNumber - 1) * pageSize) .Take(pageSize) .ToList(); return(response); }
internal void Setup() { _mapper = MapperConfiguration(); getAllAlbumsByFilterResponse = new GetAllAlbumsByFilterResponse(); getAllAlbumsByFilterResponse.ListAlbums = new List <AlbumsApp> { new AlbumsApp { Artist = "artist", Id = 1, Label = "label", Name = "name", Stock = 1 }, new AlbumsApp { Artist = "artist 2", Id = 2, Label = "label 2", Name = "name 2", Stock = 1 } }; albumAppServiceMock = new Mock <IAlbumsAppService>(); controller = new AlbumsController(albumAppServiceMock.Object, _mapper); }