public ActionResult Create(Post post) { try { // TODO: Add insert logic here post.SubmittedOn = DateTime.Now; post.UpVotes = 0; db.Posts.AddOrUpdate(post); db.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Delete(int? id, Post post) { try { // TODO: Add delete logic here Post apost = db.Posts.Find(id); db.Posts.Remove(apost); db.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(int? id, Post post) { try { // TODO: Add update logic here if (ModelState.IsValid) { db.Entry(post).State = EntityState.Modified; db.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(post); } }