public async Task <ActionResult> DeleteConfirmed(int id) { TheBlog theBlog = await db.TheBlogs.FindAsync(id); db.TheBlogs.Remove(theBlog); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
// GET: Auth/TheBlogs/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TheBlog theBlog = await db.TheBlogs.FindAsync(id); if (theBlog == null) { return(HttpNotFound()); } return(View(theBlog)); }
public async Task <ActionResult> Create([Bind(Include = "lid,Bid,Title,Date,ShortDescription,Description,Thumbnail,Image")] TheBlog theBlog, HttpPostedFileBase file, HttpPostedFileBase thumb, Helper help) { if (ModelState.IsValid) { theBlog.Image = help.uploadfile(file); theBlog.Thumbnail = help.uploadfile(thumb); db.TheBlogs.Add(theBlog); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.Bid = new SelectList(db.BlogCategories, "Bid", "Name", theBlog.Bid); return(View(theBlog)); }
public async Task <ActionResult> Edit([Bind(Include = "lid,Bid,Title,Date,ShortDescription,Description,Thumbnail,Image")] TheBlog theBlog, HttpPostedFileBase file, HttpPostedFileBase thumb1, Helper help) { if (ModelState.IsValid) { theBlog.Image = file != null?help.uploadfile(file) : img; theBlog.Thumbnail = thumb != null?help.uploadfile(thumb1) : thumb; db.Entry(theBlog).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.Bid = new SelectList(db.BlogCategories, "Bid", "Name", theBlog.Bid); return(View(theBlog)); }
// GET: Auth/TheBlogs/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TheBlog theBlog = await db.TheBlogs.FindAsync(id); img = theBlog.Image; thumb = theBlog.Thumbnail; if (theBlog == null) { return(HttpNotFound()); } ViewBag.Bid = new SelectList(db.BlogCategories, "Bid", "Name", theBlog.Bid); return(View(theBlog)); }