public ActionResult Create(Tbl_Support category) { try { if (ModelState.IsValid) { string fileName = Path.GetFileNameWithoutExtension(category.ImageFils.FileName); string extension = Path.GetExtension(category.ImageFils.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; category.ProductImage = "~/SupportImg/" + fileName; fileName = Path.Combine(Server.MapPath("~/SupportImg/"), fileName); category.ImageFils.SaveAs(fileName); category.CreatedDate = DateTime.Now; int temp = (int)(Session["BId"]); category.BId = (int)(Session["BId"]); db.Tbl_Support.Add(category); db.SaveChanges(); return(RedirectToAction("Create")); } // TODO: Add insert logic here return(View(category)); } catch { return(View()); } }
// GET: AdminSupport/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tbl_Support cat = db.Tbl_Support.Find(id); db.Tbl_Support.Remove(cat); db.SaveChanges(); if (cat == null) { return(HttpNotFound()); } return(RedirectToAction("Index")); }