public JsonResult ReNameNode(RoleTreeDateContract data) { if (data == null) throw new ArgumentNullException("the data is null!!!"); Role role = this.repository.FindBy(data.Id); role.Name = data.Name; this.repository[role.Key] = role; this.unitOfWork.Commit(); return Json(new { status = role.Status.ToString() }); }
public JsonResult Operation(RoleTreeDateContract data) { if (ReferenceEquals(data, null)) throw new ArgumentNullException("the data for manulple is null!!!!"); if (string.IsNullOrEmpty(data.Operation)) throw new ArgumentException("the operation is not allow to be null!!!"); return this.operations[data.Operation](data); }
public JsonResult GetChildren(RoleTreeDateContract data) { if (data == null) throw new ArgumentNullException("the data is null!!"); IList<Node> nodes = new List<Node>(); RoleTree tree = new RoleTree(); if (data.Id == null || !data.Id.HasValue) { nodes = tree.Roots.ToList(); foreach (var n in nodes) { n.attr.rel = "drive"; } } else { nodes = tree.GetChildren(data.Id.Value).ToList(); } return Json(nodes, JsonRequestBehavior.AllowGet); }
public JsonResult MoveNode(RoleTreeDateContract data) { return null; }
public JsonResult CreateNode(RoleTreeDateContract data) { if (data == null) throw new ArgumentNullException("the data for create node is null!!!"); Role parent = this.repository.FindBy(data.ParentId); Role role = new Role() { Name = data.Name, Parent = parent }; this.repository.Add(role); this.unitOfWork.Commit(); return Json(new { id = role.Key, status = role.Status.ToString() }); }