コード例 #1
0
        public JsonNetResult CreateWmsLayer(string data)
        {
            JsonModel jsonModel;

            try
            {
                var javascriptSerializer            = new JavaScriptSerializer();
                WmsLayerViewModel wmsLayerViewModel = javascriptSerializer.Deserialize <WmsLayerViewModel>(data);
                var viewManager = new WmsLayersViewManager(GetCurrentUser(), SessionHandler.MySettings);
                viewManager.CreateNewWmsLayer(wmsLayerViewModel);
                jsonModel = JsonModel.CreateSuccess("");
            }
            catch (Exception ex)
            {
                jsonModel = JsonModel.CreateFailure(ex.Message);
            }
            return(new JsonNetResult(jsonModel));
        }
コード例 #2
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));
        }