public async Task <ActionResult> DeleteConfirmed(int id) { Campuslife campuslife = await db.Campuslives.FindAsync(id); db.Campuslives.Remove(campuslife); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "id,Image")] Campuslife campuslife, HttpPostedFileBase file, Helper Help) { if (ModelState.IsValid) { campuslife.Image = file != null?Help.Resize(file, 600, 900) : img; db.Entry(campuslife).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(campuslife)); }
// GET: Auth/Campuslives/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Campuslife campuslife = await db.Campuslives.FindAsync(id); if (campuslife == null) { return(HttpNotFound()); } return(View(campuslife)); }
public async Task <ActionResult> Create([Bind(Include = "id,Image")] Campuslife campuslife, IEnumerable <HttpPostedFileBase> file, Helper Help) { if (ModelState.IsValid) { foreach (var a in file) { campuslife.Image = Help.Resize(a, 600, 900); db.Campuslives.Add(campuslife); await db.SaveChangesAsync(); } return(RedirectToAction("Index")); } return(View(campuslife)); }