Ejemplo n.º 1
0
 // GET: Architecture/Tree/Create
 public ActionResult Create(Guid? id)
 {
     var treeServices = ServiceLocator.Instance.GetService<ITreeServices>();
     var tree = new UpdateTree();
     if (id.HasValue)
     {
         tree = treeServices.Get(id.GetValueOrDefault());
     }
     ViewBag.UpdateTree = new HtmlString(tree.ToJson());
     return PartialView();
 }
Ejemplo n.º 2
0
 private void Add(UpdateTree updateTree)
 {
     var tree = new Tree();
     tree.ID = Guid.NewGuid();
     tree.Name = updateTree.Name;
     tree.Description = updateTree.Description;
     tree.IpAddr = updateTree.IpAddr;
     tree.CreateTime = DateTime.Now;
     using (var monitorContext = new DefaultContext())
     {
         monitorContext.Trees.Add(tree);
         monitorContext.SaveChanges();
     }
     Flag = true;
 }
Ejemplo n.º 3
0
 private void Edit(UpdateTree updateTree)
 {
     using (var monitorContext = new DefaultContext())
     {
         var tree = monitorContext.Trees.FirstOrDefault(x => x.ID == updateTree.ID);
         if (tree.Null())
         {
             Message = "请选择要修改的服务器";
             return;
         }
         tree.Name = updateTree.Name;
         tree.Description = updateTree.Description;
         tree.IpAddr = updateTree.IpAddr;
         monitorContext.ModifiedModel(tree);
         monitorContext.SaveChanges();
     }
     Flag = true;
 }
Ejemplo n.º 4
0
 public UpdateTree Get(Guid treeID)
 {
     var updateTree = new UpdateTree();
     using (var monitorContext = new DefaultContext())
     {
         var tree = monitorContext.Trees.FirstOrDefault(x => x.ID == treeID);
         if (tree.Null())
         {
             Message = "未找到要修改的服务器";
             return updateTree;
         }
         updateTree.ID = tree.ID;
         updateTree.Name = tree.Name;
         updateTree.Description = tree.Description;
         updateTree.IpAddr = tree.IpAddr;
         Flag = true;
         return updateTree;
     }
 }
Ejemplo n.º 5
0
        public ActionResult Edit(UpdateTree updateTree)
        {
            try
            {

                var treeServices = ServiceLocator.Instance.GetService<ITreeServices>();
                if (updateTree.Null())
                {
                    var failure = treeServices.GetResult();
                    return Json(failure);
                }
                treeServices.Update(updateTree);
                var result = treeServices.GetResult();
                return Json(result);
            }
            catch
            {
                return Json(1);
            }
        }
Ejemplo n.º 6
0
 public void Update(UpdateTree updateTree)
 {
     if (updateTree.ID == Guid.Empty)
     {
         Add(updateTree);
     }
     else
     {
         Edit(updateTree);
     }
 }