Exemplo n.º 1
0
 public IHttpActionResult AddOrganizeTree(dynamic data)
 {
     try
     {
         OrganizeService     os   = new OrganizeService();
         List <sys_organize> tree = new List <sys_organize>();
         foreach (var item in data)
         {
             tree.Add(new sys_organize {
                 id       = Convert.ToInt32(item.nodeid),
                 pid      = Convert.ToInt32(item.parentid),
                 status   = 1,
                 title    = item.label.ToString(),
                 code     = string.Empty,
                 address  = string.Empty,
                 email    = string.Empty,
                 fax      = string.Empty,
                 leader   = string.Empty,
                 logo     = string.Empty,
                 tel      = string.Empty,
                 add_time = DateTime.Now,
                 orgtype  = 1
             });
             if (item.children != null)
             {
                 GetChildrenData(tree, item.children);
             }
         }
         int cnt = os.SaveOrganizeTree(tree);
         return(cnt > 0 ? Json(new { code = 1, msg = "ok" }) : Json(new { code = 0, msg = "error" }));
     }
     catch (Exception e)
     {
         return(Json(new { code = 0, msg = e.Message }));
     }
 }