static void Main(string[] args) { var context = new RockContext(); var bands = context.Bands; var albums = context.Albums; // var albumCount = albums.Count(); // Console.WriteLine($"There are {albumCount} movies!"); var hasQuitTheApplication = false; while (hasQuitTheApplication == false) { Console.WriteLine("What do you want to do?"); Console.WriteLine(" View - All Bands"); Console.WriteLine(" AddBand - Add Dinosaur"); Console.WriteLine(" AddAlbum - Remove Dinosaur"); Console.WriteLine(" BandsThatAreSigned - View bands that are signed"); Console.WriteLine(" BandsThatAreNotSigned - View bands that are not signed"); Console.WriteLine(" LetBandGo - Un sign Band"); Console.WriteLine(" ReSignBand - Sign band"); Console.WriteLine(" ViewAlbumsByDate - View all albums ordered by ReleaseDate"); Console.WriteLine(" ViewBandAlbums - View Bands Albums"); Console.WriteLine(" Quit - Quit the program"); Console.WriteLine(); Console.Write("Choice: "); var choice = Console.ReadLine(); if (choice == "View") { foreach (var band in bands) { Console.WriteLine($" Band name: {band.Name}"); } } if (choice == "AddBand") { Console.Write("Name: "); var name = Console.ReadLine(); Console.Write("CountryOfOrigin: "); var origin = Console.ReadLine(); Console.Write("NumberOfMembers: "); var numberOfMembersString = Console.ReadLine(); var members = int.Parse(numberOfMembersString); Console.Write("Style: "); var style = Console.ReadLine(); Console.Write("ContactPhoneNumber: "); var contactPhoneNumberString = Console.ReadLine(); var contactPhoneNumber = Console.ReadLine(); Console.Write("IsSigned: "); var isSigned = Console.ReadLine(); Console.Write("ContactName: "); var contactName = Console.ReadLine(); var newband = new Band() { Name = name, CountryOfOrigin = origin, NumberOfMembers = members, Style = style, ContactPhoneNumber = contactPhoneNumber, IsSigned = isSigned, ContactName = contactName, }; context.Bands.Add(newband); context.SaveChanges(); } if (choice == "AddAlbum") { Console.Write("Title: "); var title = Console.ReadLine(); Console.Write("IsExplicit TRUE or FALSE: "); var isExplicit = Console.ReadLine(); Console.Write("ReleaseDate: "); var releaseDateString = Console.ReadLine(); DateTime enteredDate = DateTime.Parse(releaseDateString); Console.Write("BandId: "); var bandIdString = Console.ReadLine(); var bandId = int.Parse(bandIdString); var newAlbum = new Album() { Title = title, IsExplict = isExplicit, ReleaseDate = enteredDate, BandId = bandId, }; } if (choice == "Quit") { hasQuitTheApplication = true; } if (choice == "BandsThatAreSigned") { // Console.Write("Band name: "); // var whatBand = Console.ReadLine(); var bandsSigned = context.Bands.Where(band => band.IsSigned == "TRUE"); var bandsNames = bandsSigned.Select(band => band.Name); foreach (var bandsName in bandsNames) { Console.WriteLine($" Band name: {bandsName}"); } } if (choice == "BandsThatAreNotSigned") { var bandsSigned = context.Bands.Where(band => band.IsSigned == "FALSE"); var bandsNames = bandsSigned.Select(band => band.Name); foreach (var bandsName in bandsNames) { Console.WriteLine($"Band name: {bandsName}"); } } if (choice == "LetBandGo") { Console.Write("Band name: "); var newBand = Console.ReadLine(); var perviousBand = context.Bands.FirstOrDefault(band => band.Name == newBand); if (perviousBand != null) { perviousBand.IsSigned = "FALSE"; context.SaveChanges(); } Console.WriteLine("Task Complete"); } if (choice == "ReSignBand") { Console.Write("Band name: "); var newBandd = Console.ReadLine(); var perviousBand = context.Bands.FirstOrDefault(band => band.Name == newBandd); if (perviousBand != null) { perviousBand.IsSigned = "TRUE"; context.SaveChanges(); } Console.WriteLine("Task Complete"); } if (choice == "ViewAlbumsByDate") { // var lists = context.Albums.OrderBy(album => album.ReleaseDate).ToList(); // foreach (var list in lists) // { // Console.WriteLine(list.Title); // } } if (choice == "ViewBandAlbums") { // Console.WriteLine("Band name: "); // var nameOfBand = Console.ReadLine(); var viewBand = context.Bands.FirstOrDefault(band => band.Name == "Guns N Roses"); var albumBand = context.Albums.Include(album => album.Band); foreach (var album in albums) { var bandsAlbum = album.Title; } // var albumTitle = context.Albums.Include(album => album.Title); // var viewBandInAlbum = albumBand.viewBandInAlbum.Select(album => album.Band); // var findBands = viewBandInAlbum.Where(band => band.Name == "Guns N Roses"); // var viewBandAlbums = context.Albums.Where(album => album.Title = viewBandInAlbum); foreach (var findBand in findBands) { Console.WriteLine(findBand); } // Console.Write("Band name: "); // var bandView = Console.ReadLine(); // var context.Movies.Include(movie => movie.Rating) } } }
static void Main(string[] args) { var whileRunning = true; while (whileRunning == true) { var context = new SuncoastRecordsContext(); var theBands = context.Bands; var theAlbums = context.Album.Include(Album => Album.Band); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("--------Welcome to Suncoast Records!--------"); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("What would you like to do?:"); Console.WriteLine("Add band"); Console.WriteLine("View bands"); Console.WriteLine("Add album"); Console.WriteLine("Let band go"); Console.WriteLine("Sign band"); Console.WriteLine("View band's albums"); Console.WriteLine("View all albums"); Console.WriteLine("View signed bands"); Console.WriteLine("View unsigned bands"); Console.WriteLine("Quit"); Console.Write("Choice: "); var choice = Console.ReadLine(); if (choice == "Add band") { Console.Write("Name of the Band?(required): "); var name = Console.ReadLine(); Console.Write("Country of Origin?(required): "); var countryOfOrigin = Console.ReadLine(); Console.Write("How many members?: "); var numberOfMembers = int.Parse(Console.ReadLine()); Console.Write("What's their website?: "); var website = Console.ReadLine(); Console.Write("What style of music are they?: "); var style = Console.ReadLine(); Console.Write("Are they signed? true or false: "); var isSigned = bool.Parse(Console.ReadLine()); Console.Write("Who do we Contact?: "); var contactName = Console.ReadLine(); Console.Write("What is their contact number?: "); var contactNumber = Console.ReadLine(); var newBand = new Band { Name = name, CountryOfOrigin = countryOfOrigin, NumberofMembers = numberOfMembers, Website = website, Style = style, IsSigned = isSigned, ContactName = contactName, ContactPhoneNumber = contactNumber, }; context.Bands.Add(newBand); context.SaveChanges(); } if (choice == "View bands") { foreach (var theBand in theBands) { Console.WriteLine($"There is a band named {theBand.Name}"); } } if (choice == "Add album") { Console.Write("Name of Band: "); var bandName = Console.ReadLine(); var foundBand = context.Bands.FirstOrDefault(bands => bands.Name == bandName); if (foundBand != null) { Console.Write("Title of the album?: "); } var title = Console.ReadLine(); Console.Write("Is it explicit? true or false: "); var isExplicit = bool.Parse(Console.ReadLine()); Console.Write("When was it released?(YYYY-MM-DD): "); var releaseDate = DateTime.Parse(Console.ReadLine()); var newID = context.Bands.Max(band => band.Id); var newAlbum = new Album { Title = title, IsExplicit = isExplicit, ReleaseDate = releaseDate, BandId = newID, }; context.Album.Add(newAlbum); context.SaveChanges(); } if (choice == "Let band go") { Console.Write("Name: "); var bandName = Console.ReadLine(); var foundBand = context.Bands.FirstOrDefault(bands => bands.Name == bandName); if (foundBand != null) { Console.Write("Are you sure you want to let this band go? Yes or No: "); var unsignChoice = Console.ReadLine(); if (unsignChoice == "Yes") { if (foundBand.IsSigned == false) { Console.WriteLine($"Sorry {foundBand.Name} is already unsigned."); } else { foundBand.IsSigned = false; Console.WriteLine($"{foundBand.Name} has been let go."); context.SaveChanges(); } } else { Console.WriteLine("Returning to Menu..."); } } } if (choice == "Sign band") { Console.Write("Name: "); var bandName = Console.ReadLine(); var foundBand = context.Bands.FirstOrDefault(bands => bands.Name == bandName); if (foundBand != null) { Console.Write("Are you sure you want to sign ths band? Yes or No: "); var signChoice = Console.ReadLine(); if (signChoice == "Yes") { if (foundBand.IsSigned == true) { Console.WriteLine($"Sorry {foundBand.Name} is already signed."); } else { foundBand.IsSigned = true; Console.WriteLine($"{foundBand.Name} has been signed on!"); context.SaveChanges(); } } else { Console.WriteLine("Returning to Menu..."); } } } if (choice == "View band's albums") { Console.Write("Name of Band: "); var bandName = Console.ReadLine(); var foundBand = context.Album.FirstOrDefault(album => album.Band.Name == bandName); if (foundBand != null) { var foundAlbums = context.Album.Where(album => album.Band.Name == bandName && album.BandId == album.Band.Id); if (foundAlbums != null) { foreach (var album in foundAlbums) { Console.WriteLine($"There is an album called {album.Title} by this band"); } } else { Console.WriteLine("This band has no albums in the database."); } } } if (choice == "View all albums") { var releaseDate = theAlbums.OrderBy(theBands => theBands.ReleaseDate); foreach (var theBand in releaseDate) { Console.WriteLine($"The is an album called {theBand.Title}. It was released {theBand.ReleaseDate} "); } } if (choice == "View signed bands") { foreach (var theBand in theAlbums) { if (theBand.Band.IsSigned == true) { Console.WriteLine($"There is a signed band named {theBand.Band.Name}."); } } } if (choice == "View unsigned bands") { foreach (var theBand in theAlbums) { if (theBand.Band.IsSigned == false) { Console.WriteLine($"There is an unsigned band named {theBand.Band.Name}."); } } } if (choice == "Quit") { whileRunning = false; } } Console.WriteLine("....Have a good day...."); }
static void Main(string[] args) { var isRunning = true; while (isRunning) { if (selectedBand == null) { MenuGreeting("Main Menu."); var selection = MainMenuPrompt("Please make a selection from below:"); switch (selection) { case 0: Console.WriteLine("Goodbye."); isRunning = false; break; case 1: AddBand(); break; case 2: SelectBand(); break; case 3: ViewBands(); break; case 4: ViewAllAlbums(); break; case 5: ViewSignedBands(); break; case 6: ViewNotSignedBands(); break; default: Console.WriteLine(" Sorry, that is not a valid option."); break; } } else { MenuGreeting($"Band Menu: {selectedBand.Name}"); foreach (Album album in selectedBand.Albums) { Console.WriteLine($"{album.Title}"); } var selection = BandMenuPrompt("Please make a selection from below:"); switch (selection) { case 0: selectedBand = null; break; case 1: AddAlbum(); break; case 2: AddSong(); break; case 3: CutBand(); break; case 4: ResignBand(); break; default: Console.WriteLine(" Sorry, that is not a valid option."); break; } if (WaitForKeyOrGoBack()) { selectedBand = null; } } } }