public ActionResult Edit([Bind(Include = "Achieverid,Name,ShortDescription,Image,Course,date,Reading,Writing,Listening,Speaking,Overall")] Achievers achievers, HttpPostedFileBase file, Helper Help) { if (ModelState.IsValid) { achievers.date = System.DateTime.Now; achievers.Image = file != null?Help.uploadfile(file) : img; #region delete file string fullPath = Request.MapPath("~/UploadedFiles/" + img); if (img == achievers.Image) { } else { if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } } #endregion db.Entry(achievers).State = EntityState.Modified; db.SaveChanges(); TempData["Success"] = "Updated Successfully"; return(RedirectToAction("Index")); } return(View(achievers)); }
public ActionResult DeleteConfirmed(int id) { Achievers achievers = db.Achievers.Find(id); db.Achievers.Remove(achievers); db.SaveChanges(); TempData["Success"] = "Deleted Successfully"; return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Achieverid,Name,ShortDescription,Image,Course,date,Reading,Writing,Listening,Speaking,Overall")] Achievers achievers, HttpPostedFileBase file, Helper Help) { if (ModelState.IsValid) { achievers.date = System.DateTime.Now; achievers.Image = Help.uploadfile(file); db.Achievers.Add(achievers); db.SaveChanges(); TempData["Success"] = "Saved Successfully"; return(RedirectToAction("Index")); } return(View(achievers)); }
// GET: OfficialAdmin/Achievers/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Achievers achievers = db.Achievers.Find(id); if (achievers == null) { return(HttpNotFound()); } return(View(achievers)); }