public ActionResult CreateMap(SaveMapViewModel newMapModel) { if (ModelState.IsValid) { var id = User.Identity.GetUserId(); ObjectId oId = new ObjectId(id); MapPermissions mapPermissions = new MapPermissions(); mapPermissions.Owner = new KeyValuePair <ObjectId, MapPermissionType>(oId, MapPermissionType.RW); mapPermissions.Users = new Dictionary <ObjectId, MapPermissionType>(); mapPermissions.Groups = new Dictionary <ObjectId, MapPermissionType>(); mapPermissions.AllUsers = MapPermissionType.NA; mapPermissions.Users.Add(oId, MapPermissionType.RW); BsonDocument bMapModel = BsonDocument.Parse(newMapModel.Model); //BsonDocument bMapModel = mapModel.ToBsonDocument(); Queue <MapVersion> versions = new Queue <MapVersion>(MapVersion.VERSIONS); versions.Enqueue(new MapVersion { CreationTime = DateTime.Now, Model = bMapModel }); Map map = new Map { Name = newMapModel.Name, Creator = oId, CreationTime = DateTime.Now, Description = newMapModel.Description, Model = bMapModel, Permissions = mapPermissions, MapsArchive = versions, Followers = new HashSet <ObjectId>() }; var mId = _mapManager.AddMap(map); ObjectId mapID = new ObjectId(mId); string currentFolderIdString = _currentFolderID; ObjectId folderID = new ObjectId(currentFolderIdString); MapFolder folder = _folderManeger.GetMapFolderById(folderID); string path = folder.Model["path"].ToString(); if (path.Equals("")) { path = folder.Name; } else { path = path + "/" + folder.Name; } bMapModel.Add("path", path); map.Model = bMapModel; _mapManager.UpdateMap(map); folder.idOfMapsInFolder.Add(mapID); _folderManeger.UpdateMapFolder(folder); return(Json(new { mapId = mId, mapName = map.Name }, JsonRequestBehavior.AllowGet)); } return(Json(new { success = false })); }