Ejemplo n.º 1
0
        public async Task <bool> Add(Unidad entity)
        {
            bool response = false;

            try {
                string query = $"insert into Unidad(Nombre,Valor) values ('{entity.Nombre}','{entity.Valor}')";
                response = await managerData.Execute(query);
            } catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            return(response);
        }
Ejemplo n.º 2
0
        public async Task <bool> Add(Ingrediente entity)
        {
            bool result = false;

            try
            {
                string query = $@"Insert into Ingredientes(ProductoId,Nombre,Unidad,Cantidad)values('{entity.ProductoId}','{entity.Nombre}','{entity.Unidad}','{entity.Cantidad}')";
                result = await managerData.Execute(query);
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            return(result);
        }
Ejemplo n.º 3
0
        public async Task <bool> Add(Instruccion entity)
        {
            bool result = false;

            try
            {
                string query = $@"Insert into Instrucciones(ProductoId,Paso)values('{entity.ProductoId}','{entity.PasoDB}')";
                result = await managerData.Execute(query);
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            return(result);
        }
Ejemplo n.º 4
0
        public async Task <bool> Add(Imagen entity)
        {
            bool result = false;

            try
            {
                string query = $@"Insert into Imagenes(ProductoId,Url,Principal,Nombre,Orden)values('{entity.ProductoId}','{entity.Url}','{entity.Principal}','{entity.Nombre}','{entity.Orden}')";
                result = await managerData.Execute(query);
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            return(result);
        }
Ejemplo n.º 5
0
        public async Task <bool> Add(Producto entity)
        {
            bool result = false;

            try
            {
                string query = $@"Insert into Productos(Nombre,Guarnicion,ImagenPrincipal,Clave,Grupo,SubGrupo,Precio,Descripcion)
values('{entity.Nombre}','{entity.Guarnicion}','{entity.ImagenPrincipal}','{entity.Clave}','{entity.Grupo}','{entity.SubGrupo}','{entity.Precio}','{entity.Descripcion}')";
                result = await managerData.Execute(query);
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            return(result);
        }
Ejemplo n.º 6
0
        public async Task <bool> Add(Login entity)
        {
            bool result = false;

            try
            {
                var saltArray = Encoding.UTF8.GetBytes(Salt);
                var passArray = Encoding.UTF8.GetBytes(entity.Password);

                var ContraArray = PasswordHelper.GenerateSaltedHash(passArray, saltArray);


                var Password = Convert.ToBase64String(ContraArray);


                string query = $@"Insert into Usuarios (Usuario,Password,Nombre,Correo,Telefono,Nivel)values('{entity.Usuario}','{Password}','{entity.Nombre}','{entity.Correo}','{entity.Telefono}','{entity.Nivel}')";
                result = await managerData.Execute(query);
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            return(result);
        }
Ejemplo n.º 7
0
        public async Task CreaBaseDatos()
        {
            string nombre = ConfigurationManager.AppSettings["UrlBaseDAtos"].ToString() + ConfigurationManager.AppSettings["BaseDatosNombre"].ToString();

            con.CrearBaseDatos(nombre);
            await con.Execute(@"CREATE TABLE Imagenes (
    Id    INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    ProductoId INTEGER not null,
    Nombre    TEXT NOT NULL,
    Orden INTEGER NOT NULL DEFAULT 0,
    Url TExt NOT null,
    FechaCreacion TEXT NOT NULL DEFAULT CURRENT_DATE,
    Principal INTEGER DEFAULT 0,
    Activo    INTEGER DEFAULT 1)");

            await con.Execute(@"CREATE TABLE Ingredientes (
    Id   INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    ProductoId    INTEGER NOT NULL,
    Nombre    TEXT NOT NULL,
    Unidad    TEXT NOT NULL,
    Cantidad  NUMERIC NOT NULL,
    Activo    INTEGER DEFAULT 1)");

            await con.Execute(@"CREATE TABLE Instrucciones (
    Id    INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    ProductoId INTEGER not null,
    Paso  TEXT NOT NULL,
    Activo    INTEGER DEFAULT 1)");

            await con.Execute(@"CREATE TABLE Productos (
     Id    INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    Nombre    TEXT NOT NULL,
    FechaCreacion TEXT NOT NULL DEFAULT CURRENT_DATE,
    ImagenPrincipal   TEXT,
    Descripcion TEXT,
    Precio NUMERIC DEFAULT 0,
    Clave INTEGER DEFAULT 0,
    SubGrupo  INTEGER DEFAULT 0,
    Activo    INTEGER DEFAULT 1,
    Guarnicion    TEXT,
    Grupo INTEGER DEFAULT 0)");

            await con.Execute(@"CREATE TABLE Unidad (
    Id    INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    Valor INTEGER not null,
    Nombre    TEXT NOT NULL,
    Activo    INTEGER DEFAULT 1)");


            await con.Execute(@"CREATE TABLE 'Usuarios' (

    'Id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    'Usuario'   TEXT NOT NULL,
    'Password'  TEXT NOT NULL,
    'Nivel'     TEXT NOT NULL,
    'Nombre'    TEXT,
    'Correo'    TEXT,
    'Telefono'  TEXT)");
        }