public void MoveMapToFolder(string mapToMoveId, string moveToFolderId) { Map mapToMove = _mapDataManager.GetMapById(new ObjectId(mapToMoveId)); MapFolder moveToFolder = _mapFolderDataManager.GetMapFolderById(new ObjectId(moveToFolderId)); MapFolder oldPrevFolder = null; string userIdAsString = User.Identity.GetUserId(); ObjectId userObjectID = new ObjectId(userIdAsString); var allFoldersOfUser = _mapFolderDataManager.GetAllMapFoldersOfUser(userObjectID); var allFolderOwnedByUsr = new List <MapFolder>(); foreach (var folder in allFoldersOfUser) { if (folder.Permissions.Owner.Key.ToString().Equals(userObjectID.ToString()) && !folder.Model["type"].Equals(SharedCodedData.SHARED_SUPIRIOR)) { if (folder.idOfMapsInFolder.Contains(mapToMove.Id)) { oldPrevFolder = folder; break; } } } if (oldPrevFolder.Id.Equals(moveToFolder.Id)) { return; } oldPrevFolder.idOfMapsInFolder.Remove(mapToMove.Id); moveToFolder.idOfMapsInFolder.Add(mapToMove.Id); _mapDataManager.UpdateMap(mapToMove); _mapFolderDataManager.UpdateMapFolder(moveToFolder); _mapFolderDataManager.UpdateMapFolder(oldPrevFolder); }
// GET: Map public ActionResult Index(string id) { if (!string.IsNullOrEmpty(id)) { var mId = new ObjectId(id); var map = _mapManager.GetMapById(mId); if (map != null) { var userId = User.Identity.GetUserId(); bool isFollowing = map.Followers.Contains(new ObjectId(userId), new IDComparer()); ViewBag.isFollowing = isFollowing; MapPermissionController mpc = new MapPermissionController(); MapViewModel mvm = new MapViewModel { Id = map.Id, Name = map.Name, CreationTime = map.CreationTime, CreatorId = map.Creator, CreatorEmail = UserManager.GetEmail(map.Creator.ToString()), Description = map.Description, Model = map.Model, ModelArchive = map.MapsArchive }; if (mpc.IsMapOwner(id, User.Identity.GetUserId())) { return(View(mvm)); } else { return(View(mvm)); } } } return(RedirectToAction("Index", "Home")); }
public Dictionary <ApplicationUser, MapPermissionType> GetUsersPermissions(string mapId) { var map = _mapManager.GetMapById(new ObjectId(mapId)); Dictionary <ApplicationUser, MapPermissionType> users = new Dictionary <ApplicationUser, MapPermissionType>(); foreach (var item in map.Permissions.Users) { var user = UserManager.FindById(item.Key.ToString()); users.Add(user, item.Value); } return(users); }