Пример #1
0
 public void AddNewAlbum(Album album)
 {
     var response = Client.PostAsJsonAsync("api/Albums/Create", album).Result;
     if (response.IsSuccessStatusCode)
     {
         Console.WriteLine("Album added!");
     }
     else
     {
         Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
     }
 }
Пример #2
0
        public static void Main()
        {
            // Add an Accept header for JSON format.
            Client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            AlbumRequester albumRequester = new AlbumRequester(Client);
            SongRequester songRequester = new SongRequester(Client);
            ArtistRequester artistRequetser = new ArtistRequester(Client);

            var album = new Album
            {
                Title = "Album Title",
                Year = 2014,
                Producer = "Album Producer"
            };

            var updateAlbum = new Album
            {
                Title = "New Title",
                Year = 2014,
                Producer = "Album Producer"
            };

            albumRequester.AddNewAlbum(album);
            albumRequester.GetAllAlbums();
            albumRequester.UpdateAlbum(1, updateAlbum);
            albumRequester.GetAllAlbums();
            albumRequester.GetAlbumById(1);
            albumRequester.DeleteAlbum(1);
            albumRequester.GetAllAlbums();

            var artist = new Artist
            {
                Name = "Pesho",
                DateOfBirth = DateTime.Now
            };

            var updateArtist = new Artist
            {
                Name = "Gosho",
                DateOfBirth = DateTime.Now
            };

            artistRequetser.AddNewArtist(artist);
            artistRequetser.GetAllArtists();
            artistRequetser.UpdateArtist(1, updateArtist);
            artistRequetser.GetAllArtists();
            artistRequetser.GetArtistById(1);
            artistRequetser.DeleteArtist(1);
            artistRequetser.GetAllArtists();

            var song = new Song
            {
                Title = "Song Title",
                Year = 2014,
                Genre = "Hip-hop",
                ArtistId = 2,
                AlbumId = 2
            };

            var updateSong = new Song
            {
                Title = "New Song Title",
                Year = 2014,
                Genre = "Hip-hop"
            };

            songRequester.AddNewSong(song);
            songRequester.GetAllSongs();
            songRequester.UpdateSong(1, updateSong);
            songRequester.GetAllSongs();
            songRequester.GetSongById(1);
            songRequester.DeleteSong(1);
            songRequester.GetAllSongs();
        }
Пример #3
0
 public void UpdateAlbum(int id, Album album)
 {
     var response = Client.PutAsJsonAsync("api/Albums/Update/" + id, album).Result;
     if (response.IsSuccessStatusCode)
     {
         Console.WriteLine("Album updated!");
     }
     else
     {
         Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
     }
 }