Esempio n. 1
0
        public ActionResult Create(MasterProductsImage masterProductsImage)
        {
            try
            {
                //Ensure model state is valid
                if (ModelState.IsValid)
                {
                    //iterating through multiple file collection
                    //Checking file is available to save.
                    for (int i = 0; i < Request.Files.Count; i++)
                    {
                        var cat = Request.Files[i];

                        if (cat != null && cat.ContentLength > 0)
                        {
                            // var fileName = Path.GetFileName(file.FileName);
                            string path1 = uploadimgfile(cat);
                            MasterProductsImage fileDetail = new MasterProductsImage()
                            {
                                ProductImage = path1,
                            };
                            fileDetail.ProductID = masterProductsImage.ProductID;
                            db.masterProductsImages.Add(fileDetail);
                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            ViewBag.SportType = new SelectList(db.masterProducts, "ProductID", "ProductName");
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public ActionResult DeleteConfirmed(long id)
        {
            MasterProductsImage masterProductsImage = db.masterProductsImages.Find(id);

            db.masterProductsImages.Remove(masterProductsImage);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "ProductImageId,ProductID,ProductImage")] MasterProductsImage masterProductsImage)
 {
     if (ModelState.IsValid)
     {
         db.Entry(masterProductsImage).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductID = new SelectList(db.masterProducts, "ProductID", "Code", masterProductsImage.ProductID);
     return(View(masterProductsImage));
 }
Esempio n. 4
0
        // GET: MasterProductsImages/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MasterProductsImage masterProductsImage = db.masterProductsImages.Find(id);

            if (masterProductsImage == null)
            {
                return(HttpNotFound());
            }
            return(View(masterProductsImage));
        }
Esempio n. 5
0
        // GET: MasterProductsImages/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MasterProductsImage masterProductsImage = db.masterProductsImages.Find(id);

            if (masterProductsImage == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ProductID = new SelectList(db.masterProducts, "ProductID", "Code", masterProductsImage.ProductID);
            return(View(masterProductsImage));
        }