public ActionResult ShowActivateReplyPost(Show_Activate_Reply_Post show_Activate_Reply_Post) { User user = (User)Session["user"]; Show_Activate_Reply_Post showActivateReplyPost = db.Show_Activate_Reply_Post.Where(n => n.reply_post_id == show_Activate_Reply_Post.reply_post_id && n.user_id == user.user_id).FirstOrDefault(); if (showActivateReplyPost == null) { var idReplyPost = show_Activate_Reply_Post.reply_post_id; var idPost = db.Reply_Post.Find(idReplyPost).post_id.Value; db.Posts.Find(idPost).post_popular++; show_Activate_Reply_Post.show_activate_reply_post_datetime = DateTime.Now; show_Activate_Reply_Post.show_activate_reply_post_readed = true; show_Activate_Reply_Post.user_id = user.user_id; db.Show_Activate_Reply_Post.Add(show_Activate_Reply_Post); db.SaveChanges(); return(View()); } else { var idReplyPost = show_Activate_Reply_Post.reply_post_id; var idPost = db.Reply_Post.Find(idReplyPost).post_id.Value; db.Posts.Find(idPost).post_popular--; db.Show_Activate_Reply_Post.Remove(db.Show_Activate_Reply_Post.Find(showActivateReplyPost.show_activate_reply_post_id)); db.SaveChanges(); return(View()); } }
public ActionResult DeleteConfirmed(int id) { Show_Activate_Reply_Post show_Activate_Reply_Post = db.Show_Activate_Reply_Post.Find(id); db.Show_Activate_Reply_Post.Remove(show_Activate_Reply_Post); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "show_activate_reply_post_id,reply_post_id,user_id,show_activate_reply_post_datetime,show_activate_reply_post_readed")] Show_Activate_Reply_Post show_Activate_Reply_Post) { if (ModelState.IsValid) { db.Entry(show_Activate_Reply_Post).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.reply_post_id = new SelectList(db.Reply_Post, "reply_post_id", "reply_post_content", show_Activate_Reply_Post.reply_post_id); ViewBag.user_id = new SelectList(db.Users, "user_id", "user_pass", show_Activate_Reply_Post.user_id); return(View(show_Activate_Reply_Post)); }
// GET: Show_Activate_Reply_Post/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Show_Activate_Reply_Post show_Activate_Reply_Post = db.Show_Activate_Reply_Post.Find(id); if (show_Activate_Reply_Post == null) { return(HttpNotFound()); } return(View(show_Activate_Reply_Post)); }
// GET: Show_Activate_Reply_Post/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Show_Activate_Reply_Post show_Activate_Reply_Post = db.Show_Activate_Reply_Post.Find(id); if (show_Activate_Reply_Post == null) { return(HttpNotFound()); } ViewBag.reply_post_id = new SelectList(db.Reply_Post, "reply_post_id", "reply_post_content", show_Activate_Reply_Post.reply_post_id); ViewBag.user_id = new SelectList(db.Users, "user_id", "user_pass", show_Activate_Reply_Post.user_id); return(View(show_Activate_Reply_Post)); }