Beispiel #1
0
        public ActionResult Create(MasterSubCategory cvm, HttpPostedFileBase imgfile)
        {
            string path = uploadimgfile(imgfile);

            if (path.Equals("-1"))
            {
                ViewBag.error = "Image could not be uploaded....";
            }
            else
            {
                MasterSubCategory cat = new MasterSubCategory();
                cat.SubCatName  = cvm.SubCatName;
                cat.SubCatPhoto = path;
                cat.cat_status  = 1;
                cat.Description = cvm.Description;

                cat.isActive = false;
                if (cvm.statusex == "Yes")
                {
                    cat.isActive = true;
                }

                cat.CategoryID    = cvm.CategoryID;
                ViewBag.SportType = new SelectList(db.MasterCategorys, "CategoryID", "CatName");
                //cat.CategoryID = Convert.ToInt32(Session["FK_CategoryID"].ToString());

                db.masterSubCategories.Add(cat);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View());
        } //end,,,,,,,,,,,,,,,,,,,
Beispiel #2
0
        public ActionResult Details(int?id)
        {
            MasterSubCategory masterSubCategory = db.masterSubCategories.Find(id);


            return(View(masterSubCategory));
        }
Beispiel #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            MasterSubCategory masterSubCategory = db.masterSubCategories.Find(id);

            db.masterSubCategories.Remove(masterSubCategory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #4
0
        public ActionResult Edit(int?id)
        {
            MasterSubCategory masterSubCategory = db.masterSubCategories.Find(id);

            Session["FileName"] = masterSubCategory.SubCatPhoto;
            ViewBag.SportType   = new SelectList(db.MasterCategorys, "CategoryID", "CatName");
            return(View(masterSubCategory));
        }
Beispiel #5
0
        public ActionResult Edit(MasterSubCategory cvm, HttpPostedFileBase imgfile)
        {
            string path = "";



            var cat = db.masterSubCategories.Where(x => x.SubCategoryID == cvm.SubCategoryID).FirstOrDefault();

            if (cat.SubCatPhoto == Session["FileName"].ToString() && imgfile == null)
            {
                path = cat.SubCatPhoto;
            }
            else
            {
                path = uploadimgfile1(imgfile);
            }
            if (path.Equals("-1") && cat.SubCatPhoto != Session["FileName"].ToString())
            {
                ViewBag.error = "Image could not be uploaded....";
            }
            else
            {
                cat.SubCatName  = cvm.SubCatName;
                cat.SubCatPhoto = path;
                cat.cat_status  = 1;
                cat.Description = cvm.Description;

                cat.CategoryID    = cvm.CategoryID;
                ViewBag.SportType = new SelectList(db.MasterCategorys, "CategoryID", "CatName");
                cat.isActive      = false;
                if (cvm.statusex == "Yes")
                {
                    cat.isActive = true;
                }

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }



            return(View());
        }