public ActionResult StartSubject(int?id, string Content, string Title) //burda gelen id topictitle id si { //topic title la topic i ekleyip guncelleme yapıcam ForumTopicTitle TopicTitle = Db.ForumTopicTitles.Find(id); if (Content != null) { //burda konu ismini yazıyor ayrıca sorusunuda soruyor hem topic oluşturuyorum hemde comment oluşturuyorum ForumCommentTopic NewTopic = new ForumCommentTopic(); NewTopic.TopicTitle = Title; NewTopic.ForumComments = new List <ForumComment>(); NewTopic.ForumTopicTitle = Db.ForumTopicTitles.Find(TopicTitle.TitleId); Db.ForumCommentTopics.Add(NewTopic); Db.SaveChanges(); ForumComment NewComment = new ForumComment(); NewComment.Content = Content; int UserID = (int)Session["EnterID"]; NewComment.ByUser = Db.Users.Find(UserID); int CommentTitleID = Db.ForumCommentTopics.OrderByDescending(x => x.TopicId).Take(1).Select(x => x.TopicId).FirstOrDefault(); NewComment.CommentTopic = Db.ForumCommentTopics.Find(CommentTitleID); Db.ForumComments.Add(NewComment); Db.SaveChanges(); return(View()); } return(View()); }
public ActionResult DeleteConfirmed(int id) { ForumCommentTopic forumCommentTopic = db.ForumCommentTopics.Find(id); db.ForumCommentTopics.Remove(forumCommentTopic); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "TopicId,TopicTitle,ForumTopicTitleId")] ForumCommentTopic forumCommentTopic) { if (ModelState.IsValid) { db.Entry(forumCommentTopic).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ForumTopicTitleId = new SelectList(db.ForumTopicTitles, "TitleId", "Text", forumCommentTopic.ForumTopicTitleId); return(View(forumCommentTopic)); }
// GET: Panel/ForumCommentTopics/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ForumCommentTopic forumCommentTopic = db.ForumCommentTopics.Find(id); if (forumCommentTopic == null) { return(HttpNotFound()); } return(View(forumCommentTopic)); }
// GET: Panel/ForumCommentTopics/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ForumCommentTopic forumCommentTopic = db.ForumCommentTopics.Find(id); if (forumCommentTopic == null) { return(HttpNotFound()); } ViewBag.ForumTopicTitleId = new SelectList(db.ForumTopicTitles, "TitleId", "Text", forumCommentTopic.ForumTopicTitleId); return(View(forumCommentTopic)); }
public ActionResult StartSubject(int?id, string Content, string Title) { ForumTopicTitle TopicTitle = Db.ForumTopicTitles.Find(id); if (Content != null) { ForumCommentTopic NewTopic = new ForumCommentTopic(); NewTopic.TopicTitle = Title; NewTopic.ForumComments = new List <ForumComment>(); NewTopic.ForumTopicTitle = Db.ForumTopicTitles.Find(TopicTitle.TitleId); Db.ForumCommentTopics.Add(NewTopic); Db.SaveChanges(); ForumComment NewComment = new ForumComment(); NewComment.Content = Content; int UserID = (int)Session["EnterID"]; NewComment.ByUser = Db.Users.Find(UserID); int CommentTitleID = Db.ForumCommentTopics.OrderByDescending(x => x.TopicId).Take(1).Select(x => x.TopicId).FirstOrDefault(); NewComment.CommentTopic = Db.ForumCommentTopics.Find(CommentTitleID); Db.ForumComments.Add(NewComment); Db.SaveChanges(); return(View()); } return(View()); }