// GET: Admin/HeaderSliders/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HeaderSlider headerSlider = db.HeaderSliders.Find(id); if (headerSlider == null) { return(HttpNotFound()); } return(View(headerSlider)); }
// GET: Admin/HeaderSliders/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HeaderSlider headerSlider = db.HeaderSliders.Find(id); if (headerSlider == null) { return(HttpNotFound()); } db.HeaderSliders.Remove(headerSlider); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Image,ImageUpload,Title,Body,BtnText,BtnUrl,CreatedAt,UpdatedAt,Status")] HeaderSlider headerSlider) { try { headerSlider.Image = FileManager.Upload(headerSlider.ImageUpload); } catch (Exception e) { ModelState.AddModelError("PhotoUpload", e.Message); } if (ModelState.IsValid) { db.Entry(headerSlider).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(headerSlider)); }