public ActionResult ProductImages(Guid id, HttpPostedFileBase file)
        {
            var image = new File();

            image.FileId = Guid.NewGuid();
            if (file != null)
            {
                image.Context = new byte[file.ContentLength];
                file.InputStream.Read(image.Context, 0, file.ContentLength);
                image.ContextType = file.ContentType;
                image.Title       = file.FileName;
            }

            db.File.Add(image);

            var extera = new ExtraImages()
            {
                ProductId     = id,
                FileId        = image.FileId,
                ExtraImagesId = Guid.NewGuid()
            };

            db.ExtraImages.Add(extera);
            db.SaveChanges();
            var list = new ExtraImagesBO().GetAll().Where(c => c.ProductId == id);

            ViewBag.ProductId = id;
            return(View(list));
        }
 public ActionResult Edit([Bind(Include = "ExtraImagesId,FileId,ProductId")] ExtraImages extraImages)
 {
     if (ModelState.IsValid)
     {
         db.Entry(extraImages).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductId = new SelectList(db.Product, "ProductId", "ProductName", extraImages.ProductId);
     return(View(extraImages));
 }
        public ActionResult Create([Bind(Include = "ExtraImagesId,FileId,ProductId")] ExtraImages extraImages)
        {
            if (ModelState.IsValid)
            {
                extraImages.ExtraImagesId = Guid.NewGuid();
                db.ExtraImages.Add(extraImages);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductId = new SelectList(db.Product, "ProductId", "ProductName", extraImages.ProductId);
            return(View(extraImages));
        }
        // GET: ExtraImages/Details/5
        public ActionResult Details(Guid?id)
        {
            if (SessionParameters.User == null)
            {
                return(Redirect("/Users/Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExtraImages extraImages = db.ExtraImages.Find(id);

            if (extraImages == null)
            {
                return(HttpNotFound());
            }
            return(View(extraImages));
        }
        // GET: ExtraImages/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (SessionParameters.User == null)
            {
                return(Redirect("/Users/Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExtraImages extraImages = db.ExtraImages.Find(id);

            if (extraImages == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProductId = new SelectList(db.Product, "ProductId", "ProductName", extraImages.ProductId);
            return(View(extraImages));
        }