public async Task <ActionResult> AddDirectory(string name, string parentNodeId) { if (parentNodeId == "") { return(RedirectToAction("Index")); } Node root = AddNode(name, parentNodeId); var documenDBManager = new DocumentDBManager(); Document doc = await documenDBManager.CreateOrReplaceDocumentAsync(Settings.Default.DocumenDBDatabaseName, Settings.Default.DocumentDBCollectionName, root); HomeController.root = root; string parentName = root.Descendants().Where(n => n.NodeId == parentNodeId).First().Name; ServiceBusManager.Log("Subdirectory named " + name + " added to " + parentName + " directory by " + User.Identity.Name); return(RedirectToAction("Index")); }
public async Task <ActionResult> DeleteDirectory(string nodeId, string parentNodeId) { if (nodeId == "" || parentNodeId == "" || nodeId == "undefined" || parentNodeId == "undefined") { return(RedirectToAction("Index")); } try { var nodes = root.Descendants(); string name = nodes.Where(n => n.NodeId == nodeId).First().Name; string parentName = nodes.Where(n => n.NodeId == parentNodeId).First().Name; Node root1 = DeleteNode(nodeId, parentNodeId); var documenDBManager = new DocumentDBManager(); Document doc = await documenDBManager.CreateOrReplaceDocumentAsync(Settings.Default.DocumenDBDatabaseName, Settings.Default.DocumentDBCollectionName, root1); root = root1; ServiceBusManager.Log("Subdirectory named " + name + " removed from " + parentName + " directory by " + User.Identity.Name); } catch (Exception ex) { if (ex.Message != "Cannot delete") { throw; } } return(RedirectToAction("Index")); }