Exemple #1
0
    public static Alquiler GetTransactionAlq(int UserId, int PeliculaId)
    {
        AlquilerTableAdapter adapter = new AlquilerTableAdapter();

        Alquiler_DS.AlquilerDataTable table = adapter.ExistAlquiler(UserId, PeliculaId);
        if (table.Rows.Count == 0)
        {
            return(null);
        }
        Alquiler_DS.AlquilerRow row = table[0];
        Alquiler obj = new Alquiler()
        {
            AlquilerId     = row.AlquilerId,
            TotalPago      = row.totalPago,
            FechaAlqui     = row.fechaAlqui,
            FechaDevol     = row.fechaDevol,
            TarjetaCredito = row.tarjetaCredito,
            CodigoTarjeta  = row.codigoTarjeta,
            Estado         = row.estado,
            UserId         = row.UserId,
            PeliculaId     = row.peliculaId
        };

        return(obj);
    }
Exemple #2
0
    public static List <Alquiler> GetAllAlquileres()
    {
        AlquilerTableAdapter adapter = new AlquilerTableAdapter();

        Alquiler_DS.AlquilerDataTable table = adapter.GetAlquileres();

        List <Alquiler> result = new List <Alquiler>();
        Alquiler        temp;

        foreach (var row in table)
        {
            temp                = new Alquiler();
            temp.AlquilerId     = row.AlquilerId;
            temp.TotalPago      = row.totalPago;
            temp.FechaAlqui     = row.fechaAlqui;
            temp.FechaDevol     = row.fechaDevol;
            temp.TarjetaCredito = row.tarjetaCredito;
            temp.CodigoTarjeta  = row.codigoTarjeta;
            temp.Estado         = row.estado;
            temp.UserId         = row.UserId;
            UserCLI userTemp = UserCLI_BRL.getUserById(row.UserId);
            temp.Email      = userTemp.Email;
            temp.PeliculaId = row.peliculaId;
            Pelicula moviesTemp = Pelicula_BRL.GetPeliculaByID(row.peliculaId);
            temp.NombrePelicula = moviesTemp.Nombre;
            result.Add(temp);
        }

        return(result);
    }
Exemple #3
0
    public static List <Alquiler> GetAlquileresByUserId(int UserId)
    {
        if (UserId <= 0)
        {
            throw new ArgumentException("El UserId debe ser mayor a 0");
        }
        AlquilerTableAdapter adapter = new AlquilerTableAdapter();

        Alquiler_DS.AlquilerDataTable table = adapter.GetAlquileresByUserID(UserId);
        List <Alquiler> result = new List <Alquiler>();
        Alquiler        temp;

        foreach (var row in table)
        {
            temp = new Alquiler()
            {
                AlquilerId     = row.AlquilerId,
                TotalPago      = row.totalPago,
                FechaAlqui     = row.fechaAlqui,
                FechaDevol     = row.fechaDevol,
                TarjetaCredito = row.tarjetaCredito,
                CodigoTarjeta  = row.codigoTarjeta,
                Estado         = row.estado,
                UserId         = row.UserId,
                PeliculaId     = row.peliculaId
            };

            result.Add(temp);
        }

        return(result);
    }
Exemple #4
0
    public static Alquiler GetAlquilerByID(int AlquilerId)
    {
        if (AlquilerId <= 0)
        {
            throw new ArgumentException("El AlquilerId debe ser mayor a 0");
        }

        AlquilerTableAdapter adapter = new AlquilerTableAdapter();

        Alquiler_DS.AlquilerDataTable table = adapter.GetAlquilerByID(AlquilerId);

        if (table.Rows.Count == 0)
        {
            return(null);
        }
        Alquiler_DS.AlquilerRow row = table[0];
        Alquiler obj = new Alquiler()
        {
            AlquilerId     = row.AlquilerId,
            TotalPago      = row.totalPago,
            FechaAlqui     = row.fechaAlqui,
            FechaDevol     = row.fechaDevol,
            TarjetaCredito = row.tarjetaCredito,
            CodigoTarjeta  = row.codigoTarjeta,
            Estado         = row.estado,
            UserId         = row.UserId,
            PeliculaId     = row.peliculaId
        };

        return(obj);
    }
Exemple #5
0
    public static void DeleteAlquiler(int AlquilerId)
    {
        if (AlquilerId <= 0)
        {
            throw new ArgumentException("El AlquilerId debe ser mayor a 0");
        }
        AlquilerTableAdapter adapter = new AlquilerTableAdapter();

        adapter.Delete(AlquilerId);
    }
Exemple #6
0
    public static void UpdateAlquiler(Alquiler obj)
    {
        if (obj == null)
        {
            throw new ArgumentException("El objeto alquiler no debe ser nulo");
        }

        AlquilerTableAdapter adapter = new AlquilerTableAdapter();

        adapter.Update(obj.TotalPago, obj.FechaAlqui, obj.FechaDevol, obj.TarjetaCredito, obj.CodigoTarjeta, obj.Estado, obj.AlquilerId);
    }
Exemple #7
0
    public static int InsertAlquiler(Alquiler obj)
    {
        if (obj == null)
        {
            throw new ArgumentException("El objeto Alquiler no debe ser nulo");
        }

        AlquilerTableAdapter adapter = new AlquilerTableAdapter();
        int?AlquilerId = 0;

        adapter.Insert(obj.TotalPago, obj.FechaAlqui, obj.FechaDevol, obj.TarjetaCredito, obj.CodigoTarjeta, obj.Estado, obj.UserId, obj.PeliculaId, ref AlquilerId);

        if (AlquilerId <= 0)
        {
            throw new ArgumentException("Mala Inserción del Alquiler");
        }

        return(AlquilerId.Value);
    }
    public static List <Transaction> GetAllTransactionByUserId(int UserId)
    {
        if (UserId <= 0)
        {
            throw new ArgumentException("El UserId debe ser mayor a 1");
        }
        List <Transaction> listTransaction = new List <Transaction>();
        //Obtieniendo Compras por UserID
        CompraTableAdapter adapterCompra = new CompraTableAdapter();

        Compra_DS.CompraDataTable tableCompra = adapterCompra.GetComprasByUserID(UserId);
        Transaction tempTransaction;
        UserCLI     tempUser;
        Pelicula    tempMovie;

        foreach (var row in tableCompra)
        {
            if (row.estado)
            {
                tempTransaction                  = new Transaction();
                tempTransaction.TotalPago        = row.totalPago;
                tempTransaction.FechaTransaction = row.fecha;
                tempTransaction.UserId           = row.UserId;
                tempUser = UserCLI_BRL.getUserById(row.UserId);
                tempTransaction.UserName       = tempUser.Nombre;
                tempTransaction.EmailUser      = tempUser.Email;
                tempTransaction.TarjetaCredito = row.tarjetaCredito;
                tempTransaction.CodigoTarjeta  = row.codigoTarjeta;
                tempTransaction.PeliculaId     = row.peliculaId;
                tempMovie = Pelicula_BRL.GetPeliculaByID(row.peliculaId);
                tempTransaction.NombrePelicula = tempMovie.Nombre;
                tempTransaction.Foto           = tempMovie.Foto;
                tempTransaction.Description    = tempMovie.Descripcion;
                tempTransaction.Director       = tempMovie.Director;
                tempTransaction.Elenco         = tempMovie.Elenco;
                tempTransaction.Label          = "<span class='label label-default pull-right'" +
                                                 "style='border-radius:3px; background-color:#5cb85c; color:#fff; padding: 6px 3px'" +
                                                 ">Venta</span>";


                listTransaction.Add(tempTransaction);
            }
        }

        AlquilerTableAdapter adapterAlquiler = new AlquilerTableAdapter();

        Alquiler_DS.AlquilerDataTable tableAlquiler = adapterAlquiler.GetAlquileresByUserID(UserId);

        foreach (var row in tableAlquiler)
        {
            if (row.estado)
            {
                TimeSpan ts        = DateTime.Now - row.fechaDevol;
                int      diference = ts.Days;
                if (diference > 0)
                {
                    Alquiler_BRL.DeleteAlquiler(row.AlquilerId);
                }
                else
                {
                    tempTransaction                  = new Transaction();
                    tempTransaction.TotalPago        = row.totalPago;
                    tempTransaction.FechaTransaction = row.fechaAlqui;
                    tempTransaction.UserId           = row.UserId;
                    tempUser = UserCLI_BRL.getUserById(row.UserId);
                    tempTransaction.UserName       = tempUser.Nombre;
                    tempTransaction.EmailUser      = tempUser.Email;
                    tempTransaction.TarjetaCredito = row.tarjetaCredito;
                    tempTransaction.CodigoTarjeta  = row.codigoTarjeta;
                    tempTransaction.PeliculaId     = row.peliculaId;
                    tempMovie = Pelicula_BRL.GetPeliculaByID(row.peliculaId);
                    tempTransaction.NombrePelicula = tempMovie.Nombre;
                    tempTransaction.Foto           = tempMovie.Foto;
                    tempTransaction.Description    = tempMovie.Descripcion;
                    tempTransaction.Director       = tempMovie.Director;
                    tempTransaction.Elenco         = tempMovie.Elenco;
                    tempTransaction.Label          = "<span class='label label-default pull-right'" +
                                                     "style='border-radius:3px; background-color:#777; color:#fff; padding: 6px 3px'" +
                                                     ">Alquiler</span>";


                    listTransaction.Add(tempTransaction);
                }
            }
        }

        return(listTransaction);
    }