Esempio n. 1
0
        public ActionResult Create(int? id)
        {
            Topic topic = new Topic();
            if (id != null)
            {
                topic.TopicParentId = Convert.ToInt32(id);
            }

            return View(topic);
        }
Esempio n. 2
0
        public ActionResult Create(Topic topic)
        {
            if (ModelState.IsValid)
            {
                var sortCount = db.Topics.Max(x => (int?)x.SortOrder);
                if (sortCount != null)
                {
                    topic.SortOrder = (db.Topics.Max(x => x.SortOrder) + 1);
                }
                else
                {
                    topic.SortOrder = 1;
                }

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

            return View(topic);
        }