Ejemplo n.º 1
0
        // GET: Tree
        public ActionResult Index()
        {
            TreeEntities         db       = new TreeEntities();
            List <Tree>          list     = db.Trees.ToList();
            List <TreeViewModel> viewList = new List <TreeViewModel>();

            foreach (Tree s in list)
            {
                TreeViewModel obj = new TreeViewModel();
                obj.branches = s.branches;
                obj.leaves   = s.leaves;
                obj.nodes    = s.nodes;
                viewList.Add(obj);
            }
            return(View(viewList));
        }
Ejemplo n.º 2
0
 public ActionResult Create(TreeViewModel obj)
 {
     try
     {
         // TODO: Add insert logic here
         Tree t1 = new Tree();
         t1.leaves   = obj.leaves;
         t1.nodes    = obj.nodes;
         t1.branches = obj.branches;
         TreeEntities t2 = new TreeEntities();
         t2.Trees.Add(t1);
         t2.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }