public bool AddGroupToMap(string gId, string mapId, MapPermissionType per) { if (_mapManager.IsMapExist(new ObjectId(mapId)) && _groupManager.IsGroupExist(new ObjectId(gId)) && IsOwner(mapId)) { var map = _mapManager.GetMapById(new ObjectId(mapId)); map.Permissions.Groups[new ObjectId(gId)] = per; _mapManager.UpdateMap(map); return(true); } return(false); }
public ActionResult LaunchMap5(string id, string currentFolderID, string searchedWord) { ViewBag.res = null; _currentFolderID = currentFolderID; ViewBag.currentFolderID = currentFolderID; if (id != null && !_mapManager.IsMapExist(new ObjectId(id))) { return(RedirectToAction("index", "Home")); } if (id != null) { var userId = User.Identity.GetUserId(); MapPermissionController mpc = new MapPermissionController(); MapPermissionType userPermissionsAsUser = mpc.GetUserPermissionToMapAsUser(id, userId); MapPermissionType userPermissionsByGroup = mpc.GetUserPermissionToMapByGroup(id, userId); MapPermissionType userPermissions = MapPermissionType.NA; if (userPermissionsAsUser == MapPermissionType.RW || userPermissionsByGroup == MapPermissionType.RW) { userPermissions = MapPermissionType.RW; } else if (userPermissionsAsUser == MapPermissionType.RO || userPermissionsByGroup == MapPermissionType.RO) { userPermissions = MapPermissionType.RO; } else { return(RedirectToAction("index", "Home")); } ViewBag.userPermission = userPermissions; var map = _mapManager.GetMapById(new ObjectId(id)); int count = 0; /////centering searched word if exists if (searchedWord != null && !searchedWord.Equals("")) { var nodes = map.Model["nodeDataArray"]; foreach (var node in nodes.AsBsonArray) { string nodeText = node["text"].ToString(); if (nodeText.Contains(searchedWord)) { _mapManager.UpdateMap(map); double nodeP1 = 0; double nodeP2 = 0; var links = map.Model["linkDataArray"]; foreach (var link in links.AsBsonArray) { link["points"] = ""; } if (count == 0) { node["loc"] = ""; count++; } //node["fill"] = "#FFFF00"; } } } ViewBag.isSaved = true; ViewBag.myMap = map.Model.ToJson().ToString(); //var refIDs = GetReferencesIDsFromMapModel(map.Model.ToJson()); //var refsDict = GetReferencesFromIDs(refIDs); //ViewBag.refs = refsDict; //string t = map.Model.ToJson().ToString(); //ViewBag.myMap = JsonConvert.SerializeObject(map.Model.ToJson()); return(View(map)); } else { ViewBag.userPermission = MapPermissionType.RW; ViewBag.isSaved = false; var map = new Map { Name = "(Unsaved File)", Model = null }; ViewBag.myMap = "{}".ToJson().ToString(); return(View(map)); } }