Ejemplo n.º 1
0
        public ActionResult Move(int nodeId, int? newParentId, bool list)
        {
            if (list)
            {
                return RedirectToAction("Index");
            }

            if (nodeId == newParentId)
            {
                return RedirectToAction("Index");
            }

            using (TreeContext context = new TreeContext())
            {
                if (newParentId.HasValue && ContainsChilds(context, nodeId, newParentId.Value))
                {
                    return RedirectToAction("Index");
                }
                var node = context.Folders.Where(x => x.Id == nodeId).Single();
                node.ParentId = newParentId;
                context.SaveChanges();
            }

            return RedirectToAction("Index");
        }
Ejemplo n.º 2
0
        public ActionResult Delete(int id)
        {
            using (TreeContext context = new TreeContext())
            {
                DeleteNodes(context, id);
                context.SaveChanges();
            }

            return RedirectToAction("Index");
        }
Ejemplo n.º 3
0
        public ActionResult Add(int? parentId, string title, bool isList)
        {
            using (TreeContext context = new TreeContext())
            {
                var newFolders = new Folders()
                {
                    ParentId = parentId,
                    Title = title,
                    IsList=isList
                };
                context.Folders.Add(newFolders);
                context.SaveChanges();
            }

            return RedirectToAction("Index");
        }