示例#1
0
        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)
        {
            ForumTopicTitle forumTopicTitle = db.ForumTopicTitles.Find(id);

            db.ForumTopicTitles.Remove(forumTopicTitle);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "TitleId,Text,CommentCategoryId")] ForumTopicTitle forumTopicTitle)
 {
     if (ModelState.IsValid)
     {
         db.Entry(forumTopicTitle).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CommentCategoryId = new SelectList(db.ForumCommentCategories, "CategoryId", "CategoryName", forumTopicTitle.CommentCategoryId);
     return(View(forumTopicTitle));
 }
        // GET: Panel/ForumTopicTitles/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ForumTopicTitle forumTopicTitle = db.ForumTopicTitles.Find(id);

            if (forumTopicTitle == null)
            {
                return(HttpNotFound());
            }
            return(View(forumTopicTitle));
        }
        // GET: Panel/ForumTopicTitles/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ForumTopicTitle forumTopicTitle = db.ForumTopicTitles.Find(id);

            if (forumTopicTitle == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CommentCategoryId = new SelectList(db.ForumCommentCategories, "CategoryId", "CategoryName", forumTopicTitle.CommentCategoryId);
            return(View(forumTopicTitle));
        }
示例#6
0
        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());
        }