Exemplo n.º 1
0
        public ActionResult Create(Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.Image = db.ImageHandles.ToList();

            return View(product);
        }
Exemplo n.º 2
0
 private void SetImageUrl(Product product)
 {
     var image = db.ImageHandles.Find(product.ImageHandleId);
     product.ImageUrl = String.Format(@"{0}/{1}", image.DirectoryPath.Replace("~", "").Replace("//", "/"), image.FullFileName);
 }
Exemplo n.º 3
0
        public ActionResult Edit(Product product)
        {
            if (ModelState.IsValid)
            {
                SetImageUrl(product);
                db.Entry(product).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.Images = db.ImageHandles.Where(d => d.ImageHandleType == 3).ToList();

            return View(product);
        }