Exemple #1
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 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));
        }
        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));
        }