private void VerDetalle(Pelicula pelicula) { bool salir = false; do { Console.Clear(); Console.WriteLine($"\n\n\t\tDETALLE DE LA PELICULA CON ID {pelicula.Id}"); Console.WriteLine($"\n\n\t\tTITULO {pelicula.Titulo}"); Console.WriteLine($"\n\n\t\tGENERO {pelicula.GeneroId}"); Console.WriteLine($"\n\n\t\tEDAD RECOMENDADA {pelicula.EdadRecomendada}"); string sinopsis = pelicula.Sinopsis; for (int i = 60; i < pelicula.Sinopsis.Length; i += 60) { sinopsis = sinopsis.Insert(i, "\n\t\t\t"); } Console.WriteLine($"\n\n\t\tSINOPSIS {sinopsis}"); Console.WriteLine("\n\t\t1.ALQUILAR\t\t\t2.VOLVER\n"); Console.Write("\t\tLa opcion elegida es:..."); string opc = Console.ReadLine(); if (opc.Equals("1")) { Console.WriteLine("\n\t\tTiempo de alquiler\n"); Service.GetTiempoPrestamos().ForEach(x => { Console.WriteLine($"\t\t{x.idTiempo}.{x.Titulo}"); }); Console.Write("\t\tElija una opcion..."); int tp; bool oki = false; bool ok = Int32.TryParse(Console.ReadLine(), out tp); string res = ""; if (ok) { TiempoPrestamo tm = Service.GetTiempoPrestamo(tp); if (tm != null) { oki = Service.Alquilar(pelicula.Id, tm.idTiempo); salir = false; if (oki) { res = $"\n\t\tHAS ALQUILADO LA PELICULA {pelicula.Id}"; } else { res = $"\n\t\tYA TIENES ALQUILADA ESTA PELICULA."; salir = true; } } else { res = $"\n\t\tSELECCIONE UNA DE LAS OPCIONES MOSTRADAS."; salir = true; } } else { res = $"\n\t\tINTRODUZCA UNA OPCION VALIDA."; salir = true; } Console.WriteLine(res); Console.WriteLine($"\n\n\t\tPulse cualquier tecla para volver..."); Console.ReadKey(); } else if (opc.Equals("2")) { new Opcion3Command(0).Execute(); } else { salir = true; Console.WriteLine($"\n\n\t\tOPCION INCORRECTA!"); Console.WriteLine($"\n\n\t\tPulse cualquier tecla para volver a intentar..."); Console.ReadKey(); } } while (salir); }
private void MostrarPeliculas(string tittle, List <Pelicula> peliculas, int opt) { bool volver = false; do { Console.Clear(); Program.TablaPelicula(tittle, peliculas); Console.WriteLine("\n\t\t1.VER DETALLES\t\t\t2.ALQUILAR\t\t\t3.VOLVER"); Console.Write("\n\t\tEleccion: "); char resp = Console.ReadKey().KeyChar; switch (resp) { case '1': Console.Write("\n\n\t\tIntroduzca el ID de la pelicula para ver detalles:..."); int id1; bool ok = Int32.TryParse(Console.ReadLine(), out id1); if (ok) { Pelicula p = Service.GetPelicula(id1); if (p != null) { VerDetalle(p); volver = true; } else { Console.Write("\n\n\t\tERROR AL BUSCAR LA PELICULA"); Console.WriteLine($"\n\n\t\tPulse cualquier tecla para volver a intentarlo..."); Console.ReadKey(); volver = false; } } else { Console.Write("\n\n\t\tID DE LA PELICULA INCORRECTO"); Console.WriteLine($"\n\n\t\tPulse cualquier tecla para volver a intentarlo..."); Console.ReadKey(); volver = false; } break; case '2': Console.Write("\n\n\t\tIntroduzca el ID de la pelicula a alquilar:..."); int id2; bool ok1 = Int32.TryParse(Console.ReadLine(), out id2); if (ok1) { Console.WriteLine("\n\t\tTiempo de alquiler\n"); Service.GetTiempoPrestamos().ForEach(x => { Console.WriteLine($"\t\t{x.idTiempo}.{x.Titulo}"); }); Console.Write("\t\tElija una opcion..."); int tp; bool ok2; do { ok2 = Int32.TryParse(Console.ReadLine(), out tp); if (ok2) { Pelicula pa = Service.GetPelicula(id2); if (pa != null) { bool finish = Service.Alquilar(pa.Id, tp); if (finish) { Console.WriteLine($"\n\n\t\tLA PELICULA {pa.Id} ({pa.Titulo}) HA SIDO ALQUILADA.\n\n\t\t Pulse cualquier tecla para volver..."); volver = true; Console.ReadKey(); menu = new string[5]; menu[0] = "1.Ver todas"; menu[1] = "2.Ver por Genero"; menu[2] = "3.Ver por Edad Recomendada"; menu[3] = "4.Buscar Pelicula"; menu[4] = "5.Volver"; Program.MenuTwo(menu, 1); } else { Console.WriteLine($"\n\n\t\tYA HA ALQUILADO UN MAXIMO DE 4 PELICULAS.\n\n\t\t Pulse cualquier tecla para volver..."); volver = false; Console.ReadKey(); } } else { Console.WriteLine($"\n\n\t\tID DE LA PELICULA INCORRECTO\n\n\t\t Pulse cualquier tecla para volver..."); Console.ReadKey(); volver = false; } } else { Console.Write("\n\n\t\tOPCION ERRONEA. Elija una opciĆ³n y vuelva a intentarlo..."); Console.ReadKey(); volver = false; } } while (!ok2); } else { Console.Write("\n\n\t\tERROR AL ALQUILAR LA PELICULA"); Console.WriteLine($"\n\n\t\tPulse cualquier tecla para volver a intentarlo..."); Console.ReadKey(); volver = false; } break; case '3': volver = true; if (opt == 0) { menu = new string[5]; menu[0] = "1.Ver todas"; menu[1] = "2.Ver por Genero"; menu[2] = "3.Ver por Edad Recomendada"; menu[3] = "4.Buscar Pelicula"; menu[4] = "5.Volver"; Program.MenuTwo(menu, 1); } else if (opt > 0) { Console.WriteLine("\n\n\t\tPulse enter para volver al menu o escape para volver al inicio"); if (Console.ReadKey().Key == ConsoleKey.Escape) { menu = new string[5]; menu[0] = "1.Ver todas"; menu[1] = "2.Ver por Genero"; menu[2] = "3.Ver por Edad Recomendada"; menu[3] = "4.Buscar Pelicula"; menu[4] = "5.Volver"; Program.MenuTwo(menu, 1); } else { MostrarPeliculas(tittle, peliculas, opt); } } break; default: Console.WriteLine("\n\n\t\tOPCION INCORRECTA!"); Console.Write("\n\n\t\tPulse una tecla para continuar..."); Console.ReadKey(); volver = false; break; } } while (!volver); }