public static bool Put(Imagen imagen)
        {
            int returnValue;

            using (var model = new AlmacenDBContext())
            {
                model.Attach(imagen);
                model.Entry(imagen).Property("Tipo").IsModified = (imagen.Tipo != 0);
                model.SaveChanges();
                model.Imagenes.Add(imagen);
                returnValue = model.SaveChanges();
            }
            return(Convert.ToBoolean(returnValue));
        }
Exemple #2
0
        public static bool Put(Categoria categoria)
        {
            int returnValue;

            using (var model = new AlmacenDBContext())
            {
                model.Attach(categoria);
                model.Entry(categoria).Property("Nombre").IsModified             = !(String.IsNullOrEmpty(categoria.Nombre));
                model.Entry(categoria).Property("CategoriaProductos").IsModified = (categoria.CategoriaProductos != null);
                model.SaveChanges();
                model.Categorias.Add(categoria);
                returnValue = model.SaveChanges();
            }
            return(Convert.ToBoolean(returnValue));
        }
        public static bool Put(Bodega bodega)
        {
            int returnValue;

            using (var model = new AlmacenDBContext())
            {
                model.Attach(bodega);
                model.Entry(bodega).Property("Nombre").IsModified    = !(String.IsNullOrEmpty(bodega.Nombre));
                model.Entry(bodega).Property("Imagen").IsModified    = (bodega.Imagen != null);
                model.Entry(bodega).Property("Productos").IsModified = (bodega.Productos != null);
                model.SaveChanges();
                model.Bodegas.Add(bodega);
                returnValue = model.SaveChanges();
            }
            return(Convert.ToBoolean(returnValue));
        }
 public static bool Post(Imagen imagen)
 {
     using (var model = new AlmacenDBContext())
     {
         model.Imagenes.Add(imagen);
         model.SaveChanges();
     }
     return(Convert.ToBoolean(imagen.ImagenId));
 }
 public static bool Post(Producto producto)
 {
     using (var model = new AlmacenDBContext())
     {
         model.Productos.Add(producto);
         model.SaveChanges();
     }
     return(Convert.ToBoolean(producto.ProductoId));
 }
Exemple #6
0
 public static bool Post(Categoria categoria)
 {
     using (var model = new AlmacenDBContext())
     {
         model.Categorias.Add(categoria);
         model.SaveChanges();
     }
     return(Convert.ToBoolean(categoria.CategoriaId));
 }
 public static bool Post(Bodega bodega)
 {
     using (var model = new AlmacenDBContext())
     {
         model.Bodegas.Add(bodega);
         model.SaveChanges();
     }
     return(Convert.ToBoolean(bodega.BodegaId));
 }
        public static bool Put(Producto producto)
        {
            int returnValue;

            using (var model = new AlmacenDBContext())
            {
                model.Attach(producto);
                model.Entry(producto).Property("Nombre").IsModified             = !(String.IsNullOrEmpty(producto.Nombre));
                model.Entry(producto).Property("Descripcion").IsModified        = !(String.IsNullOrEmpty(producto.Descripcion));
                model.Entry(producto).Property("Precio").IsModified             = (producto.Precio != null);
                model.Entry(producto).Property("Imagen").IsModified             = (producto.Imagen != null);
                model.Entry(producto).Property("Bodega").IsModified             = (producto.Bodega != null);
                model.Entry(producto).Property("CategoriasProducto").IsModified = (producto.CategoriasProducto != null);
                model.SaveChanges();
                model.Productos.Add(producto);
                returnValue = model.SaveChanges();
            }
            return(Convert.ToBoolean(returnValue));
        }
        public static bool Delete(int id)
        {
            int    returnValue;
            Imagen imagen = new Imagen()
            {
                ImagenId = id
            };

            using (var model = new AlmacenDBContext())
            {
                model.Remove(imagen);
                returnValue = model.SaveChanges();
            }
            return(Convert.ToBoolean(returnValue));
        }
        public static bool Delete(int id)
        {
            int      returnValue;
            Producto producto = new Producto()
            {
                ProductoId = id
            };

            using (var model = new AlmacenDBContext())
            {
                model.Remove(producto);
                returnValue = model.SaveChanges();
            }
            return(Convert.ToBoolean(returnValue));
        }
Exemple #11
0
        public static bool Delete(int id)
        {
            int       returnValue;
            Categoria categoria = new Categoria()
            {
                CategoriaId = id
            };

            using (var model = new AlmacenDBContext())
            {
                model.Remove(categoria);
                returnValue = model.SaveChanges();
            }
            return(Convert.ToBoolean(returnValue));
        }
Exemple #12
0
        public static bool Delete(int id)
        {
            int    returnValue;
            Bodega bodega = new Bodega()
            {
                BodegaId = id
            };

            using (var model = new AlmacenDBContext())
            {
                model.Remove(bodega);
                returnValue = model.SaveChanges();
            }
            return(Convert.ToBoolean(returnValue));
        }