예제 #1
0
        public static bool Agregar(Producto product)
        {
            bool exito = false;

            try
            {
                using (var db = new ModelTiendaTecno())
                {
                    db.Producto.Add(product);
                    db.SaveChanges();
                    exito = true;
                }
            }
            catch (Exception)
            {
                exito = false;
            }

            return(exito);
        }
예제 #2
0
        public static bool Delete(int id)
        {
            bool exito = false;

            try
            {
                using (var db = new ModelTiendaTecno())
                {
                    db.Database.ExecuteSqlCommand("delete from Producto where idProducto=@id", new SqlParameter("@id", id));
                    db.Producto.Remove(db.Producto.First(i => i.idProducto == id));
                    db.SaveChanges();
                    exito = true;
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(exito);
        }
예제 #3
0
        public static bool CreatePedidoP(ProductoPedido pedido)
        {
            bool exito = false;

            try
            {
                using (var db = new ModelTiendaTecno())
                {
                    db.ProductoPedido.Add(pedido);
                    db.SaveChanges();
                    exito = true;
                }
            }
            catch (Exception)
            {
                exito = false;
            }

            return(exito);
        }