示例#1
0
        // POST: Products/Edit
        public ActionResult Edit(Product prd)
        {
            var pp = new ProductProcess();

            pp.Edit(prd);
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                var prod = productProcess.Find(id);
                var file = Request.Files[0];
                if (file.FileName != "")
                {
                    string imgName     = System.IO.Path.GetFileName(file.FileName);
                    string fisicalPath = Server.MapPath("~/images/" + imgName);
                    file.SaveAs(fisicalPath);
                    prod.Image = imgName;
                }
                prod.Title       = collection["Title"];
                prod.Description = collection["Description"];
                prod.DealerId    = Int32.Parse(collection["dealerId"]);
                prod.Price       = Double.Parse(collection["Price"]);
                prod.ChangedOn   = DateTime.Now;

                productProcess.Edit(prod);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
 public ActionResult Edit([Bind(Include = "Id,Title,Description,DealerId,Image,Price,QuantitySold,AvgStars,Rowid,CreatedOn,CreatedBy,ChangedOn,ChangedBy")] Product product)
 {
     if (ModelState.IsValid)
     {
         productProcess.Edit(product);
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
        public ActionResult DoUpdate(Product product)
        {
            // If there is not a new image, we recover the previous one
            if (product.Image == null)
            {
                Product originalProduct = _pp.Get(product.Id);
                product.Image = originalProduct.Image;
            }

            product.ChangedOn = DateTime.Now;
            product.CreatedOn = DateTime.Now;

            _pp.Edit(product);

            return(RedirectToAction("Index"));
        }