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); } }
public ActionResult PostTopic(long id, long cid) { 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(); return View(topic); }