public ActionResult Edit(string id) { if (!IsValidId(id)) { return(RedirectToAction("Index", "Home")); } try { var folder = _mapFolderDataManager.GetMapFolderById(new ObjectId(id)); var prevFolder = _mapFolderDataManager.GetMapFolderById(folder.ParentDierctory); var userID = User.Identity.GetUserId(); if (IsValidMap(folder) && folder.Permissions.Owner.Key.ToString().Equals(userID.ToString())) { var mevm = new MapEditViewModel { Id = folder.Id.ToString(), Name = folder.Name, Description = folder.Description, Path = folder.Model["path"].ToString() }; return(View(mevm)); } } catch (Exception) { return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Index", "Home")); }
public ActionResult Edit() { var regions = regionRepository.Query .Where(r => r.PolygonID != null) .Include(r => r.Polygon) .Include("Polygon.PolygonPoints") .ToList(); var vm = new MapEditViewModel(regions); return(View(vm)); }
public ActionResult Edit(MapEditViewModel model) { if (ModelState.IsValid) { try { var folder = _mapFolderDataManager.GetMapFolderById(new ObjectId(model.Id)); folder.Name = model.Name; folder.Description = model.Description; string path = model.Path; folder.Model["path"] = path; int index = path.LastIndexOf("/"); string prevPath = path.Substring(0, index); string prevFolderName = path.Substring(index + 1); var userID = User.Identity.GetUserId(); var allFoldersOfUser = _mapFolderDataManager.GetAllMapFoldersOfUser(new ObjectId(userID)); foreach (var tempFolder in allFoldersOfUser)//tempFolder represents the folder that MIGHT be the new prev folder { if (tempFolder.Name.Equals(prevFolderName) && prevPath.Equals(tempFolder.Model["path"].ToString())) { var prevFolder = _mapFolderDataManager.GetMapFolderById(folder.ParentDierctory); prevFolder.idOfSubFolders.Remove(folder.Id); tempFolder.idOfSubFolders.Add(folder.Id); folder.ParentDierctory = tempFolder.Id; _mapFolderDataManager.UpdateMapFolder(prevFolder); _mapFolderDataManager.UpdateMapFolder(tempFolder); _mapFolderDataManager.UpdateMapFolder(folder); return(RedirectToAction("Details", "MapFolder", new { id = model.Id })); } } // _mapFolderDataManager.UpdateMapFolder(folder); // return RedirectToAction("Details", "MapFolder", new { id = model.Id }); } catch { return(View(model)); } } return(View(model)); }
// GET: Map/Edit/5 public ActionResult Edit(string id) { if (!IsValidId(id)) { return(RedirectToAction("Index", "Home")); } try { var map = _mapManager.GetMapById(new ObjectId(id)); if (IsValidMap(map) && _mapManager.IsMapOwner(map.Id.ToString(), User.Identity.GetUserId())) { var mevm = new MapEditViewModel { Id = map.Id.ToString(), Name = map.Name, Description = map.Description }; return(View(mevm)); } } catch (Exception e) { return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Index", "Home")); }
public async Task <ActionResult> EditMap(int id) { var user = await GetCurrentUserAsync(); var viewModel = new MapEditViewModel(); viewModel.ApplicationUsers = await _context.ApplicationUsers .Where(user => user.UserType == "venue") .ToListAsync(); viewModel.ApplicationUserId = user.Id; var foundTour = await _context.Tours .Where(tour => tour.TourId == id) .FirstOrDefaultAsync(); viewModel.TourToEdit = foundTour; viewModel.Destinations = await _context.Destinations .Where(destination => destination.TourId == foundTour.TourId) .ToListAsync(); return(View(viewModel)); }
public ActionResult Edit(MapEditViewModel model) { if (ModelState.IsValid) { try { var map = _mapManager.GetMapById(new ObjectId(model.Id)); map.Name = model.Name; map.Description = model.Description; string path = model.Path; string mapPath = map.Model["path"].ToString(); map.Model["path"] = path; string prevFolderPathNew; string prevFolderNameNew; int index = path.LastIndexOf("/"); if (index < 0) { prevFolderPathNew = ""; prevFolderNameNew = path; } else { prevFolderPathNew = path.Substring(0, index); prevFolderNameNew = path.Substring(index + 1); } index = mapPath.LastIndexOf("/"); string prevFolderPathInMap; string prevFolderNameInMap; if (index < 0) { prevFolderPathInMap = ""; prevFolderNameInMap = path; } else { prevFolderPathInMap = mapPath.Substring(0, index); prevFolderNameInMap = mapPath.Substring(index + 1); } var userID = User.Identity.GetUserId(); var allFoldersOfUser = _folderManeger.GetAllMapFoldersOfUser(new ObjectId(userID)); foreach (var folderOfMap in allFoldersOfUser) { if (folderOfMap.Name.Equals(prevFolderNameInMap) && prevFolderPathInMap.Equals(folderOfMap.Model["path"].ToString())) { folderOfMap.idOfMapsInFolder.Remove(map.Id); _folderManeger.UpdateMapFolder(folderOfMap); break; } } foreach (var tempFolder in allFoldersOfUser)//tempFolder represents the folder that MIGHT be the new prev folder { if (tempFolder.Name.Equals(prevFolderNameNew) && prevFolderPathNew.Equals(tempFolder.Model["path"].ToString())) { tempFolder.idOfMapsInFolder.Add(map.Id); _folderManeger.UpdateMapFolder(tempFolder); return(RedirectToAction("Details", "MapFolder", new { id = model.Id })); } } } catch { return(View(model)); } } return(View(model)); }
public void ProcessInput(InputManager input) { MapEditViewModel vm = (MapEditViewModel)DataContext; DevForm.ExecuteOrInvoke(() => vm.ProcessInput(input)); }