コード例 #1
0
 public EmptyResult UpdateNode(EmployeeNodeModel model)
 {
     try
     {
         if (entities.OrgchartUser.Find(model.id) == null)
         {
             AddNode(model);
         }
         else
         {
             var node = entities.OrgchartUser.Single(p => p.id == model.id);
             if (node != null)
             {
                 node.name  = model.name;
                 node.pid   = model.pid;
                 node.title = model.title;
                 node.id    = model.id;
                 entities.Entry(node).State = System.Data.Entity.EntityState.Modified;
                 entities.SaveChanges();
                 return(new EmptyResult());
             }
         }
     } catch (Exception ex)
     {
         return(new EmptyResult());
     }
     return(new EmptyResult());
 }
コード例 #2
0
        public JsonResult AddNode(EmployeeNodeModel model)
        {
            OrgchartUser employee = new OrgchartUser();

            employee.id    = model.id;
            employee.pid   = model.pid;
            employee.name  = model.name;
            employee.title = model.title;
            entities.OrgchartUser.Add(employee);
            entities.SaveChanges();

            return(Json(new { id = employee.id }, JsonRequestBehavior.AllowGet));
        }