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,,,,,,,,,,,,,,,,,,,
public ActionResult Details(int?id) { MasterSubCategory masterSubCategory = db.masterSubCategories.Find(id); return(View(masterSubCategory)); }
public ActionResult DeleteConfirmed(int id) { MasterSubCategory masterSubCategory = db.masterSubCategories.Find(id); db.masterSubCategories.Remove(masterSubCategory); db.SaveChanges(); return(RedirectToAction("Index")); }
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)); }
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()); }