Exemple #1
0
        static void AddAlbum()
        {
            var    context = new BrokenRecordLabelContext();
            string moreAlbumsToAdd;

            do
            {
                var newAlbum = new Album();
                newAlbum.Title = GetDetails("title", "album", "add");
                string isExplicit;
                do
                {
                    Console.Write($"Is {newAlbum.Title} explicit? 'YES' or 'NO': ");
                    isExplicit = Console.ReadLine().ToUpper().Trim();
                } while (isExplicit != "YES" && isExplicit != "NO");
                if (isExplicit == "YES")
                {
                    newAlbum.IsExplicit = true;
                }
                else
                {
                    newAlbum.IsExplicit = false;
                }
                newAlbum.ReleaseDate = GetReleaseDate();

                Console.Write($"\nWho's the band that made {newAlbum.Title}? ");
                var albumBand = context.Bands.FirstOrDefault(band => band.Name == Console.ReadLine());
                newAlbum.BandId = albumBand.Id;
                context.Albums.Add(newAlbum);
                Console.Write("\nWould you like to add another album? 'YES' or 'NO': ");
                moreAlbumsToAdd = Console.ReadLine().ToUpper().Trim();
            } while (moreAlbumsToAdd == "YES");
            context.SaveChanges();
        }
Exemple #2
0
        static void SignUnsign(bool sign)
        {
            var context = new BrokenRecordLabelContext();
            var bandToSignOrUnsignsName = GetDetails("name", "band", "");
            var bandToSignOrUnsign      = context.Bands.FirstOrDefault(band => band.Name == bandToSignOrUnsignsName);

            if (sign)
            {
                bandToSignOrUnsign.IsSigned = true;
                Console.WriteLine($"{bandToSignOrUnsign.Name} were successfully signed!");
            }
            else
            {
                bandToSignOrUnsign.IsSigned = false;
                Console.WriteLine($"\n{bandToSignOrUnsign.Name} were successfully released!");
            }
            context.SaveChanges();
        }
Exemple #3
0
        static void AddSong()
        {
            var    context = new BrokenRecordLabelContext();
            string moreSongsToAdd;

            do
            {
                var newSong = new Song();
                newSong.Title = GetDetails("title", "song", "add");
                Console.Write("\nWhat is the song's duration? Proper format is 'hr:mn:sc': ");
                newSong.Duration = Console.ReadLine();
                Console.Write($"\nWho's the album that contains {newSong.Title}? ");
                var songAlbum       = context.Albums.FirstOrDefault(album => album.Title == Console.ReadLine());
                var allSongsOnAlbum = context.Songs.Where(song => song.AlbumId == songAlbum.Id);
                newSong.AlbumId     = songAlbum.Id;
                newSong.TrackNumber = allSongsOnAlbum.Count() + 1;
                context.Songs.Add(newSong);
                Console.Write("\nWould you like to add another album? 'YES' or 'NO': ");
                moreSongsToAdd = Console.ReadLine().ToUpper().Trim();
            } while (moreSongsToAdd == "YES");
            context.SaveChanges();
        }
Exemple #4
0
        static void AddBand()
        {
            var    context = new BrokenRecordLabelContext();
            string moreBandsToAdd;

            do
            {
                var newBand = new Band();
                newBand.Name            = GetDetails("name", "band", "add");
                newBand.NumberOfMembers = GetMemberAmount();
                newBand.CountryOfOrigin = GetDetails("country of origin", newBand.Name, "");
                newBand.Website         = GetDetails("website", newBand.Name, "");
                newBand.Style           = GetDetails("style", newBand.Name, "");
                string isSigned;
                do
                {
                    Console.Write($"Is {newBand.Name} signed? 'YES' or 'NO': ");
                    isSigned = Console.ReadLine().ToUpper().Trim();
                } while (isSigned != "YES" && isSigned != "NO");
                if (isSigned == "YES")
                {
                    newBand.IsSigned = true;
                }
                else
                {
                    newBand.IsSigned = false;
                }
                newBand.ContactName = GetDetails("contact name", newBand.Name, "");
                Console.Write($"What is {newBand.ContactName}'s number? Numbers only please: ");
                newBand.ContactPhoneNumber = GetContactPhoneNumber();
                context.Bands.Add(newBand);
                Console.Write("\nWould you like to add another band? 'YES' or 'NO': ");
                moreBandsToAdd = Console.ReadLine().ToUpper().Trim();
            } while (moreBandsToAdd == "YES");
            context.SaveChanges();
        }