public ActionResult DeleteConfirmed(int id) { Tick_Post tick_Post = db.Tick_Post.Find(id); db.Tick_Post.Remove(tick_Post); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "tick_post_id,post_id,user_id,tick_post_datetime,tick_recyclebin")] Tick_Post tick_Post) { if (ModelState.IsValid) { db.Entry(tick_Post).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.post_id = new SelectList(db.Posts, "post_id", "post_content", tick_Post.post_id); ViewBag.user_id = new SelectList(db.Users, "user_id", "user_pass", tick_Post.user_id); return(View(tick_Post)); }
// GET: Tick_Post/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tick_Post tick_Post = db.Tick_Post.Find(id); if (tick_Post == null) { return(HttpNotFound()); } return(View(tick_Post)); }
// GET: Tick_Post/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tick_Post tick_Post = db.Tick_Post.Find(id); if (tick_Post == null) { return(HttpNotFound()); } ViewBag.post_id = new SelectList(db.Posts, "post_id", "post_content", tick_Post.post_id); ViewBag.user_id = new SelectList(db.Users, "user_id", "user_pass", tick_Post.user_id); return(View(tick_Post)); }
public ActionResult SaveTickPost(Tick_Post tick_Post) { User user = (User)Session["user"]; Tick_Post tickPost = db.Tick_Post.Where(n => n.post_id == tick_Post.post_id && n.user_id == user.user_id).FirstOrDefault(); if (tickPost == null) { db.Posts.Find(tick_Post.post_id).post_popular++; tick_Post.user_id = user.user_id; tick_Post.tick_recyclebin = false; tick_Post.tick_post_datetime = DateTime.Now; db.Tick_Post.Add(tick_Post); db.SaveChanges(); return(View()); } else { db.Posts.Find(tick_Post.post_id).post_popular--; db.Tick_Post.Remove(db.Tick_Post.Find(tickPost.tick_post_id)); db.SaveChanges(); return(View()); } }