Example #1
0
        public void DeleteSongArtist(int id)
        {
            var artist = Artists.SingleOrDefault(x => x.Id == id);

            if (artist != null)
            {
                Artists.Remove(artist);
            }
            this.SaveChanges();
        }
Example #2
0
        public void UpdateSongArtist(int id, Artist updatedSongArtist)
        {
            var artist = Artists.SingleOrDefault(x => x.Id == id);

            if (artist != null)
            {
                artist.Name      = updatedSongArtist.Name;
                artist.FirstName = updatedSongArtist.FirstName;
            }
            this.SaveChanges();
        }
Example #3
0
        public Logic()
        {
            //genre
            Generes = File.ReadAllLines("CSVData/Genre.csv", Encoding.UTF8)
                      .Select(l => l.Split(';'))
                      .Skip(1)
                      .Select(data => new Genre
            {
                Id   = Convert.ToInt32(data[0]),
                Name = data[1]
            }).ToArray();

            //artist
            Artists = File.ReadAllLines("CSVData/Artist.csv", Encoding.UTF8)
                      .Select(l => l.Split(';'))
                      .Skip(1)
                      .Select(data => new Artist
            {
                Id   = Convert.ToInt32(data[0]),
                Name = data[1]
            }).ToArray();


            //album
            Albums = File.ReadAllLines("CSVData/Album.csv", Encoding.UTF8)
                     .Select(l => l.Split(';'))
                     .Skip(1)
                     .Select(data => new Album
            {
                Id       = Convert.ToInt32(data[0]),
                title    = data[1],
                ArtistId = Convert.ToInt32(data[2]),
                artist   = Artists.SingleOrDefault(e => e.Id == Convert.ToInt32(data[2]))
            }).ToArray();

            //Track
            //Id;Name;AlbumId;GenreId;Composer;Milliseconds;Bytes;UnitPrice
            Track = File.ReadAllLines("CSVData/Track.csv", Encoding.UTF8)
                    .Select(l => l.Split(';'))
                    .Skip(1)
                    .Select(data => new Track
            {
                Id           = Convert.ToInt32(data[0]),
                Name         = data[1],
                AlbumId      = Convert.ToInt32(data[2]),
                GenreId      = Convert.ToInt32(data[3]),
                Composer     = data[4],
                Milliseconds = Convert.ToInt32(data[5]),
                Bytes        = Convert.ToInt32(data[6]),
                UnitPrice    = 1
            }).ToArray();
        }