Ejemplo n.º 1
0
        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() });
        }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 public JsonResult MoveNode(RoleTreeDateContract data)
 {
     return null;
 }
Ejemplo n.º 5
0
        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() });
        }