Exemple #1
0
        public ActionResult Edit(HttpPostedFileBase image, Brand brand, string oldimg)
        {
            db.Entry(brand).State = EntityState.Modified;
            db.Entry(brand).Property(t => t.status).IsModified = false;
            if (image == null)
            {
                db.Entry(brand).Property(m => m.image).IsModified = false;
            }
            else
            {
                var myAccount = new Account {
                    ApiKey = "826331127339442", ApiSecret = "8SQi6Vti80ZwES3LeeBDFnSqBWQ", Cloud = "dycqowxvx"
                };
                Cloudinary _cloudinary = new Cloudinary(myAccount);

                //delete
                _cloudinary.DeleteResources(oldimg);

                //upload
                var uploadParams = new ImageUploadParams()
                {
                    File = new FileDescription(image.FileName, image.InputStream)
                };
                var uploadResult = _cloudinary.Upload(uploadParams);
                brand.image = uploadResult.SecureUri.AbsoluteUri;
            }


            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit(Usuario usuario)
 {
     if (ModelState.IsValid)
     {
         db.Entry(usuario).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idEstadoUsuario = new SelectList(db.UsuarioEstado, "idEstado", "descripcion", usuario.idEstadoUsuario);
     return(View(usuario));
 }
Exemple #3
0
 public ActionResult Edit([Bind(Include = "id,name,hash,status")] Color color)
 {
     if (ModelState.IsValid)
     {
         db.Entry(color).State = EntityState.Modified;
         db.Entry(color).Property(t => t.status).IsModified = false;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(color));
 }
 public ActionResult Edit([Bind(Include = "idProducto,idSubCategoria,descripcion,idTalle,precioUnitario,idGarantia,idColor,fotoUrl")] Producto producto)
 {
     if (ModelState.IsValid)
     {
         db.Entry(producto).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idCategoria = new SelectList(db.Categoria, "idSubCategoria", "descripcion", producto.idSubCategoria);
     ViewBag.idColor     = new SelectList(db.Color, "idColor", "descripcion", producto.idColor);
     ViewBag.idGarantia  = new SelectList(db.Garantia, "idGarantia", "descripcion", producto.idGarantia);
     ViewBag.idTalle     = new SelectList(db.Talle, "idTalle", "descripcion", producto.idTalle);
     return(View(producto));
 }
        public async Task <IHttpActionResult> PutTaxes_Level(int id, Taxes_Level taxes_Level)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != taxes_Level.IdTax_Level)
            {
                return(BadRequest());
            }

            db.Entry(taxes_Level).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Taxes_LevelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> PutOrder_Details(int id, Order_Details order_Details)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != order_Details.IdOrder)
            {
                return(BadRequest());
            }

            db.Entry(order_Details).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Order_DetailsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #7
0
        public async Task <IHttpActionResult> PutShippment_Methods(int id, Shippment_Methods shippment_Methods)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != shippment_Methods.IdShippment_Method)
            {
                return(BadRequest());
            }

            db.Entry(shippment_Methods).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Shippment_MethodsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> PutGroup(int id, Group group)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != group.IdGroup)
            {
                return(BadRequest());
            }

            db.Entry(group).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GroupExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #9
0
        public async Task <IHttpActionResult> PutLogin_informations(int id, Login_informations login_informations)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != login_informations.IdLogin_information)
            {
                return(BadRequest());
            }

            db.Entry(login_informations).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Login_informationsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public ActionResult Edit([Bind(Include = "idCupon,cantidad,codigo,fechaCaducidad,porcentajeDescuento,descripcion")] Cupon cupon)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cupon).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cupon));
 }
Exemple #11
0
 public ActionResult Edit([Bind(Include = "idBanco,nombre")] Banco banco)
 {
     if (ModelState.IsValid)
     {
         db.Entry(banco).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(banco));
 }
 public ActionResult Edit([Bind(Include = "idCategoria,descripcion")] Categoria categoria)
 {
     if (ModelState.IsValid)
     {
         db.Entry(categoria).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(categoria));
 }
 public ActionResult Edit(Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
 public ActionResult Edit([Bind(Include = "idTalle,descripcion")] Talle talle)
 {
     if (ModelState.IsValid)
     {
         db.Entry(talle).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(talle));
 }
Exemple #15
0
 public ActionResult Edit([Bind(Include = "id,name,catId,status")] SubCategory subCategory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(subCategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.catId = new SelectList(db.Categories, "id", "name", subCategory.catId);
     return(View(subCategory));
 }
Exemple #16
0
 public ActionResult Edit([Bind(Include = "idSubCategoria,idCategoria,descripcion")] SubCategoria subCategoria)
 {
     if (ModelState.IsValid)
     {
         db.Entry(subCategoria).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idCategoria = new SelectList(db.Categoria, "idCategoria", "descripcion", subCategoria.idCategoria);
     return(View(subCategoria));
 }
Exemple #17
0
 public ActionResult Edit([Bind(Include = "idCostoEnvio,idLocalidad,Importe")] CostoEnvio costoEnvio)
 {
     if (ModelState.IsValid)
     {
         db.Entry(costoEnvio).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idLocalidad = new SelectList(db.Localidad, "id", "localidad1", costoEnvio.idLocalidad);
     return(View(costoEnvio));
 }
Exemple #18
0
 public ActionResult Edit([Bind(Include = "datosPersonalesId,nombre,apellido,dni,idDireccion")] DatosPersonales datosPersonales)
 {
     if (ModelState.IsValid)
     {
         db.Entry(datosPersonales).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idDireccion = new SelectList(db.Direccion, "idDireccion", "direccion1", datosPersonales.idDireccion);
     return(View(datosPersonales));
 }
 public ActionResult Edit([Bind(Include = "idUsuario,userName,email,idEstadoUsuario,idDatosPersonales")] Usuario usuario)
 {
     if (ModelState.IsValid)
     {
         db.Entry(usuario).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idEstadoUsuario = new SelectList(db.UsuarioEstado, "idEstado", "descripcion", usuario.idEstadoUsuario);
     return(View(usuario));
 }
Exemple #20
0
 public ActionResult Edit([Bind(Include = "idSucursal,idDireccion,telefono,email,descripcion")] Sucursal sucursal)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sucursal).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idDireccion = new SelectList(db.Direccion, "idDireccion", "direccion1", sucursal.idDireccion);
     return(View(sucursal));
 }
 public ActionResult Edit([Bind(Include = "idStock,idSucursal,idProducto,cantidad,minimo,maximo")] Stock stock)
 {
     if (ModelState.IsValid)
     {
         db.Entry(stock).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idProducto = new SelectList(db.Producto, "idProducto", "descripcion", stock.idProducto);
     ViewBag.idSucursal = new SelectList(db.Sucursal, "idSucursal", "descripcion", stock.idSucursal);
     return(View(stock));
 }
        public ActionResult editPedidosDetalles(FormCollection formCollection)
        {
            string id            = formCollection["id"];
            string estatus       = formCollection["estatus"];
            string observaciones = formCollection["observaciones"];
            int    e;
            var    orden = db.PEDIDO_PROVEEDOR.Find(int.Parse(id));

            if (estatus.Equals("Autorizado"))
            {
                e = 0;
            }
            else
            {
                e = 2;
            }
            orden.AUTORIZADO          = e;
            orden.OBSERVACIONES       = observaciones;
            orden.FECHA_ACTUALIZACION = System.DateTime.Now;
            db.Entry(orden).State     = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            ViewBag.showSuccessAlert = true;
            return(RedirectToAction("Pedidos", "Finanzas"));
        }
Exemple #23
0
 public ActionResult ShopBasket(FormCollection form)
 {
     if (ModelState.IsValid)
     {
         String[] claves = form.AllKeys;
         foreach (string clave in claves)
         {
             string             id    = clave.Split('_')[1];
             string             valor = form[clave];
             OrdenCompraDetalle ocd   = db.OrdenCompraDetalle.Find(Convert.ToInt32(id));
             ocd.cantidad        = Convert.ToInt32(valor);
             db.Entry(ocd).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     return(RedirectToAction("ShopBasket"));
 }
Exemple #24
0
        public ActionResult Update(Product product, int[] colorId, int[] sizeId, HttpPostedFileBase[] image)
        {
            db.Entry(product).State = EntityState.Modified;
            db.SaveChanges();
            int a = 0;

            for (int i = 0; i < image.Count(); i++)
            {
                a++;
            }
            if (a > 1)
            {
                var myAccount = new Account {
                    ApiKey = "826331127339442", ApiSecret = "8SQi6Vti80ZwES3LeeBDFnSqBWQ", Cloud = "dycqowxvx"
                };
                Cloudinary _cloudinary = new Cloudinary(myAccount);

                foreach (var img in image)
                {
                    var uploadParams = new ImageUploadParams()
                    {
                        File = new FileDescription(img.FileName, img.InputStream)
                    };
                    var   uploadResult = _cloudinary.Upload(uploadParams);
                    Image imagenew     = new Image();
                    imagenew.url       = uploadResult.SecureUri.AbsoluteUri;
                    imagenew.productId = product.id;
                    db.Images.Add(imagenew);
                    db.SaveChanges();
                }
            }

            List <ProductColor> colors = db.ProductColors.Where(w => w.productId == product.id).ToList();

            foreach (var c in colors)
            {
                db.ProductColors.Remove(c);
                db.SaveChanges();
            }
            for (int i = 0; i < colorId.Count(); i++)
            {
                ProductColor productColor = new ProductColor();
                productColor.colorId   = colorId[i];
                productColor.productId = product.id;
                db.ProductColors.Add(productColor);
                db.SaveChanges();
            }


            List <ProductSize> sizes = db.ProductSizes.Where(w => w.productId == product.id).ToList();

            foreach (var s in sizes)
            {
                db.ProductSizes.Remove(s);
                db.SaveChanges();
            }

            for (int z = 0; z < sizeId.Count(); z++)
            {
                ProductSize productSize = new ProductSize();
                productSize.sizeId    = sizeId[z];
                productSize.productId = product.id;
                db.ProductSizes.Add(productSize);
                db.SaveChanges();
            }



            return(RedirectToAction("Index"));
        }