public ActionResult Create([Bind(Include = "UserName,Password,LastName,FirstName,Email,City,Country,ImgPath,Interests")] User user) { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(View(user)); }
public ActionResult Create([Bind(Include = "CommentId,ThreadId,ParentCommentId,UserName,Date,Content")] Comment comment) { if (ModelState.IsValid) { db.Comments.Add(comment); db.SaveChanges(); return(RedirectToAction("Details", "Home", new { id = comment.ThreadId })); } ViewBag.ParentCommentId = new SelectList(db.Comments, "CommentId", "UserName", comment.ParentCommentId); ViewBag.ThreadId = new SelectList(db.Threads, "ThreadId", "Title", comment.ThreadId); ViewBag.UserName = new SelectList(db.Users, "UserName", "Password", comment.UserName); return(View(comment)); }
// GET: Home/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Thread thread = db.Threads.Find(id); if (thread == null) { return(HttpNotFound()); } List <Comment> comments = (from c in db.Comments where c.ThreadId == id && c.ParentCommentId == null select c).ToList <Comment>(); ViewBag.Comment = comments; thread.Views++; db.SaveChanges(); return(View(thread)); }