public static List <Compra> GetAllCompras() { CompraTableAdapter adapter = new CompraTableAdapter(); Compra_DS.CompraDataTable table = adapter.GetCompras(); List <Compra> result = new List <Compra>(); Compra temp; foreach (var row in table) { temp = new Compra(); temp.CompraId = row.CompraId; temp.Fecha = row.fecha; temp.TotalPago = row.totalPago; 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); }
public static List <Compra> GetComprasByUserID(int UserId) { if (UserId <= 0) { throw new ArgumentException("El UserId no debe ser menor igual a 0"); } CompraTableAdapter adapter = new CompraTableAdapter(); Compra_DS.CompraDataTable table = adapter.GetComprasByUserID(UserId); List <Compra> result = new List <Compra>(); Compra temp; foreach (var row in table) { temp = new Compra(); temp.CompraId = row.CompraId; temp.Fecha = row.fecha; temp.TotalPago = row.totalPago; 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); }
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); }
public static Compra GetCompraByID(int CompraId) { if (CompraId <= 0) { throw new ArgumentException("La CompraID debe ser mayor a 0"); } CompraTableAdapter adapter = new CompraTableAdapter(); Compra_DS.CompraDataTable table = adapter.GetCompraByID(CompraId); if (table.Rows.Count == 0) { return(null); } Compra_DS.CompraRow row = table[0]; Compra obj = new Compra(); obj.CompraId = row.CompraId; obj.Fecha = row.fecha; obj.TotalPago = row.totalPago; obj.TarjetaCredito = row.tarjetaCredito; obj.CodigoTarjeta = row.codigoTarjeta; obj.Estado = row.estado; obj.UserId = row.UserId; UserCLI userTemp = UserCLI_BRL.getUserById(row.UserId); obj.Email = userTemp.Email; obj.PeliculaId = row.peliculaId; Pelicula movieTemp = Pelicula_BRL.GetPeliculaByID(row.peliculaId); obj.NombrePelicula = movieTemp.Nombre; return(obj); }
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); }