public static IOperation createOperation(TYPE type) { IOperation operation = null; switch (type) { case TYPE.ALBUM: operation = new AlbumOperation(); break; case TYPE.ARTIST: operation = new ArtistOperation(); break; case TYPE.GENRE: operation = new GenreOperation(); break; case TYPE.SONG: operation = new SongOperation(); break; } return(operation); }
public void PrintSongMenu() { int caseMainMenu = -1; while (caseMainMenu != 0) { if (AuthenticationService.LoggedUser.IsAdmin == true) { Console.WriteLine(".............SONG MENU FOR ADMIN............."); Console.WriteLine("1 - Add new song"); Console.WriteLine("2 - Update song"); Console.WriteLine("3 - Get all song"); Console.WriteLine("4 - Get song by ID"); Console.WriteLine("5 - Delete song"); Console.WriteLine("Press any other key to exit"); Console.WriteLine("............................................."); int operationInt = Convert.ToInt32(Console.ReadLine()); SongOperation operation = (SongOperation)operationInt; switch (operation) { case SongOperation.Add: AddSong(); break; case SongOperation.Update: UpdateSong(); break; case SongOperation.GetAll: GetAllSongs(); break; case SongOperation.DisplayByID: DisplaySongByID(); break; case SongOperation.Delete: DeleteSong(); break; default: break; } } else { Console.WriteLine(".............SONG MENU FOR USER............."); Console.WriteLine("1 - Get all songs"); Console.WriteLine("2 - Get song by ID"); Console.WriteLine("Press any other key to exit"); Console.WriteLine("............................................"); int operationInt = Convert.ToInt32(Console.ReadLine()); SongOperation operation = (SongOperation)operationInt; switch (operation) { case SongOperation.GetAll: GetAllSongs(); break; case SongOperation.DisplayByID: DisplaySongByID(); break; default: break; } } Console.WriteLine("0 - Go back to main menu"); Console.WriteLine("1 - Stay in song menu"); caseMainMenu = Convert.ToInt32(Console.ReadLine()); } }