public ActionResult EditWmsLayer(int id) { var viewManager = new WmsLayersViewManager(GetCurrentUser(), SessionHandler.MySettings); WmsLayerEditorViewModel model = viewManager.CreateWmsLayerEditorViewModel(WmsLayerEditorMode.Edit, id); return(View("WmsLayerEditor", model)); }
public ActionResult WmsLayers() { WmsLayersViewManager viewManager = new WmsLayersViewManager(GetCurrentUser(), SessionHandler.MySettings); var model = viewManager.CreateWmsLayersViewModel(); return(View(model)); }
public RedirectToRouteResult WmsLayerEditorSaveChanges(int id, string data) { var javascriptSerializer = new JavaScriptSerializer(); WmsLayerViewModel wmsLayerViewModel = javascriptSerializer.Deserialize <WmsLayerViewModel>(data); var viewManager = new WmsLayersViewManager(GetCurrentUser(), SessionHandler.MySettings); viewManager.UpdateWmsLayer(id, wmsLayerViewModel); return(RedirectToAction("WmsLayers")); }
/// <summary> /// Returns all WMS layers stored in MySettings /// </summary> /// <returns></returns> public JsonNetResult GetWmsLayers() { JsonModel jsonModel; try { var viewManager = new WmsLayersViewManager(GetCurrentUser(), SessionHandler.MySettings); List <WmsLayerViewModel> wmsLayers = viewManager.GetWmsLayers(); jsonModel = JsonModel.Create(wmsLayers); } catch (Exception ex) { jsonModel = JsonModel.CreateFailure(ex.Message); } return(new JsonNetResult(jsonModel)); }
/// <summary> /// Removes the specified WMS layers. /// </summary> /// <param name="wmsLayerIds">WMS layer ids.</param> /// <returns></returns> public JsonNetResult RemoveWmsLayers(int[] wmsLayerIds) { JsonModel jsonModel; try { var viewManager = new WmsLayersViewManager(GetCurrentUser(), SessionHandler.MySettings); viewManager.RemoveWmsLayers(wmsLayerIds); jsonModel = JsonModel.CreateSuccess(""); } catch (Exception ex) { jsonModel = JsonModel.CreateFailure(ex.Message); } return(new JsonNetResult(jsonModel)); }
public JsonNetResult RemoveWmsLayer(string data) { JsonModel jsonModel; try { var javascriptSerializer = new JavaScriptSerializer(); WmsLayerViewModel wmsLayerViewModel = javascriptSerializer.Deserialize <WmsLayerViewModel>(data); var viewManager = new WmsLayersViewManager(GetCurrentUser(), SessionHandler.MySettings); viewManager.RemoveWmsLayer(wmsLayerViewModel.Id); jsonModel = JsonModel.CreateSuccess(""); } catch (Exception ex) { jsonModel = JsonModel.CreateFailure(ex.Message); } return(new JsonNetResult(jsonModel)); }
/// <summary> /// Handle AddWmsLayer and EditWmsLayer Post. /// </summary> private ActionResult WmsLayerEditorPost(WmsLayerEditorMode mode, int?id, string data) { var viewManager = new WmsLayersViewManager(GetCurrentUser(), SessionHandler.MySettings); var javascriptSerializer = new JavaScriptSerializer(); WmsLayerViewModel wmsLayerViewModel = javascriptSerializer.Deserialize <WmsLayerViewModel>(data); if (ModelState.IsValid) { if (mode == WmsLayerEditorMode.Edit) { viewManager.UpdateWmsLayer(id.Value, wmsLayerViewModel); } else { viewManager.CreateNewWmsLayer(wmsLayerViewModel); } return(RedirectToAction("WmsLayers")); } WmsLayerEditorViewModel model = viewManager.CreateWmsLayerEditorViewModel(mode, id); return(View("WmsLayerEditor", model)); }