public ActionResult DeleteConfirmed(string id) { EventsAndDecoration eventsAndDecoration = db.EventsAndDecorations.Find(id); db.EventsAndDecorations.Remove(eventsAndDecoration); db.SaveChanges(); return(RedirectToAction("Index")); }
//public ActionResult DeleteProducts(int? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // var eventsAndDecoration = db.EventsAndDecorations.Find(id); // if (eventsAndDecoration == null) // { // return HttpNotFound(); // } // string currentImg = Request.MapPath(eventsAndDecoration.DecorationImage); // db.Entry(eventsAndDecoration).State = EntityState.Deleted; // if (db.SaveChanges() > 0) // { // if (System.IO.File.Exists(currentImg)) // { // System.IO.File.Delete(currentImg); // } // TempData["msg"] = "Data Deleted"; // return RedirectToAction("Index"); // } // return View(); //} public ActionResult Delete(string id) { /* if (id == null) * { * return new HttpStatusCodeResult(HttpStatusCode.BadRequest); * }*/ EventsAndDecoration eventsAndDecoration = db.EventsAndDecorations.Find(id); if (eventsAndDecoration == null) { return(HttpNotFound()); } return(View(eventsAndDecoration)); }
public ActionResult AddEVentsandDecoration(EventsAndDecoration image) { string fileName = Path.GetFileNameWithoutExtension(image.ImageFile.FileName); string extension = Path.GetExtension(image.ImageFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; // image.Id = 90; image.DecorationImage = "~/Image/" + fileName; fileName = Path.Combine(Server.MapPath("~/Image/"), fileName); image.ImageFile.SaveAs(fileName); using (ProjectEventManagementEntities1 db = new ProjectEventManagementEntities1()) { db.EventsAndDecorations.Add(image); db.SaveChanges(); } ModelState.Clear(); string message = "Events dded Successfully"; ViewBag.Mesage = message; return(View()); }