예제 #1
0
        public ActionResult Create([Bind(Include="TopicID,Topic1,TopicURL,Search,Tags,CategoryID,UserId,TimeStamp")] Topic topic)
        {
            if (ModelState.IsValid)
            {
                // If user is logged in, get UserID. To get to this point, user must be logged in.
                if (User.Identity.IsAuthenticated)
                {
                    var userName = User.Identity.Name;
                    Identity ident = new Identity();

                    topic.UserId = ident.GetUserID(userName);
                }
                else
                {
                    topic.UserId = 0;
                }

                SearchTools st = new SearchTools();

                topic.TopicURL = st.CreateSearchURL(topic.Topic1);
                topic.TimeStamp = DateTime.Now;

                entVote.Topics.Add(topic);
                entVote.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.CategoryID = new SelectList(entVote.CategoryLists, "CategoryID", "Category", topic.CategoryID);
            return View(topic);
        }
예제 #2
0
        public void TestMethod1()
        {
            SearchTools st = new SearchTools();

            string url = st.CreateSearchURL("the fox ran into the woods");
        }