예제 #1
0
        public ActionResult Database(TablesetEditorViewModel viewModel)
        {
            questStatus            status = null;
            TablesetsListViewModel tablesetsListViewModel = null;

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Log Operation
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = LogOperation();
            if (!questStatusDef.IsSuccess(status))
            {
                tablesetsListViewModel             = new TablesetsListViewModel(this.UserSession, viewModel);
                tablesetsListViewModel.questStatus = status;
                return(View("Index", viewModel));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Authorize
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = Authorize(viewModel._ctx);
            if (!questStatusDef.IsSuccess(status))
            {
                tablesetsListViewModel             = new TablesetsListViewModel(this.UserSession, viewModel);
                tablesetsListViewModel.questStatus = status;
                return(View("Index", viewModel));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Read tableset for the database Id
            *---------------------------------------------------------------------------------------------------------------------------------*/
            TablesetId tablesetId = new TablesetId(viewModel.Id);
            TablesetEditorViewModel tablesetEditorViewModel = null;
            TablesetEditorModeler   tablesetEditorModeler   = new TablesetEditorModeler(this.Request, this.UserSession);

            status = tablesetEditorModeler.Read(tablesetId, out tablesetEditorViewModel);
            if (!questStatusDef.IsSuccess(status))
            {
                tablesetsListViewModel             = new TablesetsListViewModel(this.UserSession, viewModel);
                tablesetsListViewModel.questStatus = status;
                return(View("Index", viewModel));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Return view.
            *---------------------------------------------------------------------------------------------------------------------------------*/
            DatabaseEditorViewModel databaseEditorViewModel = new DatabaseEditorViewModel(this.UserSession, viewModel);

            databaseEditorViewModel.Id          = tablesetEditorViewModel.DatabaseId;
            databaseEditorViewModel.questStatus = new questStatus(Severity.Warning);
            return(View("~/Areas/Setup/Views/Database/Index.cshtml", databaseEditorViewModel));
        }
예제 #2
0
        public ActionResult Save(TablesetEditorViewModel tablesetEditorViewModel)
        {
            questStatus status = null;

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Log Operation
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = LogOperation();
            if (!questStatusDef.IsSuccess(status))
            {
                tablesetEditorViewModel.questStatus = status;
                return(Json(tablesetEditorViewModel, JsonRequestBehavior.AllowGet));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Authorize
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = Authorize(tablesetEditorViewModel._ctx);
            if (!questStatusDef.IsSuccess(status))
            {
                tablesetEditorViewModel.questStatus = status;
                return(Json(tablesetEditorViewModel, JsonRequestBehavior.AllowGet));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Perform operation.
            *---------------------------------------------------------------------------------------------------------------------------------*/
            bool bInitialCreation = tablesetEditorViewModel.Id < BaseId.VALID_ID ? true : false;
            TablesetEditorModeler tablesetEditorModeler = new TablesetEditorModeler(this.Request, this.UserSession);

            status = tablesetEditorModeler.Save(tablesetEditorViewModel);
            if (!questStatusDef.IsSuccessOrWarning(status))
            {
                tablesetEditorViewModel.questStatus = status;
                return(Json(tablesetEditorViewModel, JsonRequestBehavior.AllowGet));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Return result.
            *---------------------------------------------------------------------------------------------------------------------------------*/
            if (questStatusDef.IsWarning(status))
            {
                tablesetEditorViewModel.questStatus = status;
            }
            else
            {
                status = new questStatus(Severity.Success, "Tableset successfully" + (bInitialCreation ? " created" : " updated"));
            }
            tablesetEditorViewModel.questStatus = status;
            return(Json(tablesetEditorViewModel, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public ActionResult Delete(TablesetEditorViewModel tablesetEditorViewModel)
        {
            questStatus status = null;

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Log Operation
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = LogOperation();
            if (!questStatusDef.IsSuccess(status))
            {
                // TODO
                throw new Exception("LogOperation failed");
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Authorize
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = Authorize(tablesetEditorViewModel._ctx);
            if (!questStatusDef.IsSuccess(status))
            {
                // TODO
                throw new Exception("Authorize failed");
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Perform operation.
            *---------------------------------------------------------------------------------------------------------------------------------*/
            TablesetId            tablesetId            = new TablesetId(tablesetEditorViewModel.Id);
            TablesetEditorModeler tablesetEditorModeler = new TablesetEditorModeler(this.Request, this.UserSession);

            status = tablesetEditorModeler.Delete(tablesetId);
            if (!questStatusDef.IsSuccess(status))
            {
                tablesetEditorViewModel.questStatus = status;
                return(Json(tablesetEditorViewModel, JsonRequestBehavior.AllowGet));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Return result.
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = new questStatus(Severity.Success, "Tableset successfully deleted");
            tablesetEditorViewModel.questStatus = status;
            return(Json(tablesetEditorViewModel, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        public ActionResult TablesetIdOptions()
        {
            questStatus status = null;


            /*----------------------------------------------------------------------------------------------------------------------------------
            * Log Operation
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = LogOperation();
            if (!questStatusDef.IsSuccess(status))
            {
                UserMessageModeler userMessageModeler = new UserMessageModeler(status);
                return(Json(userMessageModeler.UserMessage, JsonRequestBehavior.AllowGet));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Authorize
            *---------------------------------------------------------------------------------------------------------------------------------*/
            status = Authorize();
            if (!questStatusDef.IsSuccess(status))
            {
                UserMessageModeler userMessageModeler = new UserMessageModeler(status);
                return(Json(userMessageModeler.UserMessage, JsonRequestBehavior.AllowGet));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Perform Operation
            *---------------------------------------------------------------------------------------------------------------------------------*/
            List <OptionValuePair> optionValuePairList   = null;
            TablesetEditorModeler  tablesetEditorModeler = new TablesetEditorModeler(this.Request, this.UserSession);

            status = tablesetEditorModeler.GetTablesetOptions(out optionValuePairList);
            if (!questStatusDef.IsSuccess(status))
            {
                UserMessageModeler userMessageModeler = new UserMessageModeler(status);
                return(Json(userMessageModeler.UserMessage, JsonRequestBehavior.AllowGet));
            }

            /*----------------------------------------------------------------------------------------------------------------------------------
            * Respond
            *---------------------------------------------------------------------------------------------------------------------------------*/
            return(Json(optionValuePairList, JsonRequestBehavior.AllowGet));
        }