Beispiel #1
0
        public static TiempoPrestamo GetTiempoPrestamo(int id)
        {
            string         query = $"Select * From TiemposReservas where idTiempo = {id}";
            TiempoPrestamo tp    = null;

            Conexion.Open();
            SqlCommand cmd =
                new SqlCommand(query, Conexion);
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                tp          = new TiempoPrestamo();
                tp.idTiempo = Convert.ToInt32(reader[0].ToString());
                tp.Titulo   = reader[1].ToString();
                tp.Dias     = Convert.ToInt32(reader[2].ToString());
            }

            Conexion.Close();
            return(tp);
        }
Beispiel #2
0
        public static List <TiempoPrestamo> GetTiempoPrestamos()
        {
            string query             = "Select * From TiemposReservas";
            List <TiempoPrestamo> tp = new List <TiempoPrestamo>();

            Conexion.Open();
            SqlCommand cmd =
                new SqlCommand(query, Conexion);
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                TiempoPrestamo t = new TiempoPrestamo();
                t.idTiempo = Convert.ToInt32(reader[0].ToString());
                t.Titulo   = reader[1].ToString();
                t.Dias     = Convert.ToInt32(reader[2].ToString());

                tp.Add(t);
            }

            Conexion.Close();
            return(tp);
        }
Beispiel #3
0
        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);
        }