Пример #1
0
        private static void AlbumsMenu()
        {
            var albumsClient = new AlbumsClient(client);
            var isRunning    = true;

            while (isRunning)
            {
                Console.Clear();
                Console.WriteLine("Music Data System Console Client");
                Console.WriteLine("            Albums");
                Console.WriteLine();
                Console.WriteLine("( 1 ) Create Album");
                Console.WriteLine("( 2 ) Get All Albums");
                Console.WriteLine("( 3 ) Get Album by ID");
                Console.WriteLine("( 4 ) Update Album");
                Console.WriteLine("( 5 ) Delete Album");
                Console.WriteLine("( 6 ) Get Album's Artists");
                Console.WriteLine("( 7 ) Get Album's Songs");
                Console.WriteLine("( 0 ) Exit");
                Console.WriteLine();
                Console.Write("Enter a number [0..7]:");
                var key = Console.ReadKey();

                switch (key.KeyChar)
                {
                case '1': albumsClient.CreateAlbum();
                    break;

                case '2': albumsClient.GetAllAlbums();
                    break;

                case '3': albumsClient.GetAlbum();
                    break;

                case '4': albumsClient.UpdateAlbum();
                    break;

                case '5': albumsClient.DeleteAlbum();
                    break;

                case '6': albumsClient.GetAlbumArtists();
                    break;

                case '7': albumsClient.GetAlbumSongs();
                    break;

                case '0': isRunning = false;
                    break;

                default:
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(" Incorrect choice!");
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Thread.Sleep(1000);
                    break;
                }
            }
        }
Пример #2
0
        public AlbumsTest()
        {
            var httpClient = new HttpClient {
                BaseAddress = new Uri("https://jsonplaceholder.typicode.com")
            };

            _instance = new AlbumsClient(httpClient);
        }
Пример #3
0
        /// <summary>
        ///     Creates a new instance of GeniusClient
        /// </summary>
        /// <param name="accessToken">Access Token to make authorized requests.</param>
        public GeniusClient(string accessToken)
        {
            IApiConnection apiConnection = new ApiConnection(accessToken);

            AccountsClient    = new AccountsClient(apiConnection);
            AlbumsClient      = new AlbumsClient(apiConnection);
            AnnotationsClient = new AnnotationsClient(apiConnection);
            ArtistsClient     = new ArtistsClient(apiConnection);
            VoteClient        = new VoteClient(apiConnection);
            ReferentsClient   = new ReferentsClient(apiConnection);
            SongsClient       = new SongsClient(apiConnection);
            SearchClient      = new SearchClient(apiConnection);
            WebPagesClient    = new WebPagesClient(apiConnection);
        }