58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SQLite;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using compabetov2.database;
|
|
using compabetov2.database.modelos;
|
|
|
|
namespace compabetov2.database
|
|
{
|
|
internal class service
|
|
{
|
|
public static bool iniciarSesion(Usuario usuario)
|
|
{
|
|
return DAO.iniciarSesionDAO(usuario.nombreUsuario, usuario.contra);
|
|
}
|
|
|
|
public static List<Producto> conseguirProductos()
|
|
{
|
|
List<Producto> productos = new List<Producto>();
|
|
|
|
SQLiteDataReader reader = DAO.conseguirProductosDAO();
|
|
|
|
while (reader.Read())
|
|
{
|
|
Categoria categoria = new Categoria(
|
|
(int)reader["idcategoria"],
|
|
reader["nombre"].ToString(),
|
|
reader["descripcion"].ToString());
|
|
|
|
Producto producto = new Producto(
|
|
(int)reader["idproducto"],
|
|
reader["nombre"].ToString(),
|
|
reader["descripcion"].ToString(),
|
|
(decimal)reader["precio"],
|
|
reader["img"].ToString(),
|
|
(int)reader["stock"],
|
|
categoria);
|
|
|
|
productos.Add(producto);
|
|
}
|
|
|
|
return productos;
|
|
}
|
|
|
|
public static bool insertarProducto(Producto producto)
|
|
{
|
|
return DAO.insertarProductoDAO(producto);
|
|
}
|
|
|
|
public static bool insertarCategoriaDAO(Categoria categoria)
|
|
{
|
|
return DAO.insertarCategoriaDAO(categoria);
|
|
}
|
|
}
|
|
}
|