Beispiel #1
0
        public ActionResult AddTopic(ForumTopic forumTopic)
        {
            //string[] splits = values.Split(':');
            //ForumTopic forumTopic = new ForumTopic();
            //if (splits.Length == 3)
            //{

            //    forumTopic.Category = splits[0];
            //    forumTopic.Name = splits[1];
            //    forumTopic.Description = splits[2];
            //}
            string name = Membership.GetUser().UserName;
            myprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
            forumTopic.createdUser = myprofile;
            //forumTopic.groupId = ViewBag.GroupID;
            ViewBag.CategoryList = followPeersDB.Specializations.Select(s => s.SpecializationName).ToList();

            if (ModelState.IsValid && forumTopic.Category != null && forumTopic.Category != "")
            {
                var toAddInto = followPeersDB.Forums.Single(f => f.Category == forumTopic.Category);
                toAddInto.Topics.Add(forumTopic);
                followPeersDB.SaveChanges();
                ViewBag.TopicAdded = "true";
            }

            Console.WriteLine(forumTopic.createdUser.FirstName);
            return RedirectToAction("TopicDetail", "Forum", new { id = forumTopic.ForumTopicId });

            //return View(forumTopic);
        }
Beispiel #2
0
        public ActionResult AddTopic(ForumTopic forumTopic)
        {
            ViewBag.CategoryList = db.Specializations.Select(s => s.SpecializationName).ToList();

            if (ModelState.IsValid && forumTopic.Category != null && forumTopic.Category != "")
            {
                var toAddInto = db.Forums.Single(f => f.Category == forumTopic.Category);
                toAddInto.Topics.Add(forumTopic);
                db.SaveChanges();
                ViewBag.TopicAdded = "true";
            }
            return View(forumTopic);
        }
        public ActionResult AddTopic(ForumTopic forumTopic)
        {
            string name = Membership.GetUser().UserName;
            UserProfile myprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
            forumTopic.createdUser = myprofile;
            forumTopic.groupId = pubcategory.ToString();
            ViewBag.CategoryList = followPeersDB.Specializations.Select(s => s.SpecializationName).ToList();
            if (forumTopic.Category != null && forumTopic.Category != "")
            {
                var toAddInto = followPeersDB.Forums.Single(f => f.Category == forumTopic.Category);
                toAddInto.Topics.Add(forumTopic);
                followPeersDB.SaveChanges();
                ViewBag.TopicAdded = "true";
            }

            return RedirectToAction("TopicDetail", "Forum", new { id = forumTopic.ForumTopicId });
        }