Ejemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "ID,ProductName,ShortDescription,ImageURL, FullDescription,UnitPrice,CategoryID")] Product product, HttpPostedFileBase image)
        {
            // is image passed?
            if (image != null)
            {
                uploadAzureBlobStorage(product, image);
            }

            // keep the current image
            else
            {
                Product productDB = db.Products.Find(product.ID);
                product.ImageURL          = productDB.ImageURL;
                db.Entry(productDB).State = EntityState.Detached;
            }

            if (ModelState.IsValid)
            {
                db.Entry(product).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CategoryID = new SelectList(db.Categories, "ID", "CategoryName", product.CategoryID);
            return(View(product));
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "ID,CategoryName,Description")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Ejemplo n.º 3
0
        public void Edit(Employee employee)
        {
            if (employee is null)
            {
                throw new ArgumentException(nameof(employee));
            }

            _dbContext.Attach(employee);
            _dbContext.Entry(employee).State = EntityState.Modified;
        }
Ejemplo n.º 4
0
 public virtual void Update(T entity)
 {
     dbSet.Attach(entity);
     dataContext.Entry(entity).State = EntityState.Modified;
 }