示例#1
0
        public ActionResult EditWmsLayer(int id)
        {
            var viewManager = new WmsLayersViewManager(GetCurrentUser(), SessionHandler.MySettings);
            WmsLayerEditorViewModel model = viewManager.CreateWmsLayerEditorViewModel(WmsLayerEditorMode.Edit, id);

            return(View("WmsLayerEditor", model));
        }
示例#2
0
        public ActionResult WmsLayers()
        {
            WmsLayersViewManager viewManager = new WmsLayersViewManager(GetCurrentUser(), SessionHandler.MySettings);
            var model = viewManager.CreateWmsLayersViewModel();

            return(View(model));
        }
示例#3
0
        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"));
        }
示例#4
0
        /// <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));
        }
示例#5
0
        /// <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));
        }
示例#6
0
        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));
        }
示例#7
0
        /// <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));
        }