Esempio n. 1
0
        public ActionResult Add(int?n)
        {
            student.Models.Tie insert = new Models.Tie();
            if (n != null)
            {
                TempData["id"] = n;
            }

            return(View(insert));
        }
Esempio n. 2
0
        public ActionResult TestJson(int id)
        {
            Models.Tie tie1 = db.Ties.Where(t => t.id == id).FirstOrDefault();
            List <Models.TieContent> tieclist = db.TieContents.Where(t => t.Tie_id == id).ToList();
            string str = "[";
            int    j   = 1;

            foreach (var item in tieclist)
            {
                List <Models.hf> hf = db.hfs.Where(h => h.TieContent_id == item.id).ToList();
                if (hf.Count == 0)
                {
                    str += "{\"tiecontent\":\"" + item.tie_content + "\"";
                }
                else
                {
                    str += "{\"tiecontent\":\"" + item.tie_content + "\",\"hf\":[";
                }
                int i = 1;
                foreach (var item1 in hf)
                {
                    if (i != hf.Count)
                    {
                        str += "{\"tiecontent\":\"" + item1.hf_content + "\"},";
                    }
                    else
                    {
                        str += "{\"tiecontent\":\"" + item1.hf_content + "\"}]";
                    }

                    i++;
                }

                if (j != tieclist.Count)
                {
                    str += "},";
                }
                else
                {
                    str += "}]";
                }

                j++;
            }
            student.DAL.JsonChange a = new JsonChange();
            var b = a.JsonToObject(str);

            ViewBag.j = b;
            return(View());
        }