コード例 #1
0
        public ActionResult ViewTopic(long id, long catid, VTopicModel vt)
        {
            VTopicModel viewTop = new VTopicModel();

            viewTop.Vtp = (from ft in db.ForumTopics
                           join me in db.Mems on ft.memsid equals me.memsid
                           where ft.TopicId == id && ft.IsApproved == "Y"
                           select new ViewTopicModel
                           {
                               TopicId = ft.TopicId,
                               TopicDesc = ft.TopicDesc,
                               TopicTitle = ft.TopicTitle,
                               fname = me.fname,
                               Photo = me.gimg,
                               SubCatId = ft.SubCatId,
                               memsid = ft.memsid,
                               UpdateCandiId = ft.UpdateCandiId.ToString(),
                               UpdateCandiName = ft.UpdateCandiName,
                               UpdateDate = ft.UpdateDate.ToString(),
                               StartDate = ft.StartDate.ToString(),
                               LastAnsId = db.ForumTopics.Where(c => c.memsid == me.memsid).Count(),
                               TotalThread = db.ForumSubCategories.Where(c => c.SubCatId == ft.SubCatId).Count(),
                               TotalReplay = db.ForumTopicAnswers.Where(c => c.TopicId == ft.TopicId).Count(),
                           }).FirstOrDefault();



            long memid = Convert.ToInt32(Request.Cookies["memsid"].Value);
            string fname = Request.Cookies["fname"].Value;
            if (vt.insAns.TopicAns != null)
            {
                if (ModelState.IsValid)
                {

                    commonFun rpb = new commonFun();
                    string tpans = string.Empty;

                    tpans = rpb.ReplaceBadWords(vt.insAns.TopicAns);

                    int i = db.forumInsertAnswer(id, tpans, memid, System.DateTime.Now, fname);

                    if (i > 0)
                    {
                        ViewBag.Success = true;
                        ViewBag.Message = "Reply Posted Successfully Queued For Approval";
                        return View(viewTop);
                    }
                    else
                    {
                        ViewBag.Success = false;
                        ViewBag.Message = "Unable to Post";
                        return View(viewTop);
                    }
                }
            }
            else
            {
                ViewBag.Success = false;
                ViewBag.Message = "Unable to Post";
                return View(viewTop);
            }
            return View(viewTop);
        }
コード例 #2
0
        public ActionResult PostTopic(long id, long cid, posttopicModel ins)
        {
            posttopicModel topic = new posttopicModel();

            topic.forumcategory = (from s in db.ForumSubCategories
                                   join m in db.Mems on s.memsid equals m.memsid
                                   where s.SubCatId == id
                                   select new forumcat
                                   {
                                       CatID = s.CatId,
                                       SubCatId = s.SubCatId,
                                       SubCatTitle = s.SubCatTitle,
                                       SubCatDesc = s.SubCatDesc,
                                       memsid = m.memsid,
                                       fname = m.fname,
                                       lname = m.lname,
                                       lastupdate = s.UpdatedDate.ToString(),
                                       gimg = m.gimg,
                                       TopicsCount = db.ForumTopics.Where(c => c.SubCatId == s.SubCatId).Count(),
                                       ReplyCount = db.ForumTopicAnswers.Join(db.ForumTopics, f => f.TopicId, o => o.TopicId, (f, o) => new { f.AnsId, o.SubCatId })
                                       .Where(f => f.SubCatId == s.SubCatId).Count()

                                   }).FirstOrDefault();

            long memid = Convert.ToInt32(Request.Cookies["memsid"].Value);
            string fname = Request.Cookies["fname"].Value;

            commonFun rtp = new commonFun();

            if (ModelState.IsValid)
            {
                string topicttl = rtp.ReplaceBadWords(ins.insertTp.topicTitle);
                string topicdesc = rtp.ReplaceBadWords(ins.insertTp.topicDesc);

                int i = db.forumInsertTopic(topicttl, topicdesc, cid, id, memid, fname, memid, System.DateTime.Now, System.DateTime.Now);
                if (i > 0)
                {
                    ViewBag.Success = true;

                    ViewBag.Message = "Topic posted successfully Queued For approval";
                    return View(topic);
                }
                else
                {
                    ViewBag.Success = false;
                    ViewBag.Message = "Unable to Post";
                    return View(topic);
                }

            }
            else
            {
                ViewBag.Success = false;
                ViewBag.Message = "Unable to Post";
                return View(topic);
            }

        }