예제 #1
0
        public JsonResult Manage(SQLCommandHistoryModel model, GridManagingModel manageModel)
        {
            if (ModelState.IsValid || manageModel.Operation == GridOperationEnums.Del)
            {
                return Json(_sqlCommandServices.ManageSQLCommandHistory(manageModel.Operation, model));
            }

            return Json(new ResponseModel
            {
                Success = false,
                Message = GetFirstValidationResults(ModelState).Message
            });
        }
예제 #2
0
        /// <summary>
        /// Manage user group
        /// </summary>
        /// <param name="operation">the operation</param>
        /// <param name="model">the user group model</param>
        /// <returns></returns>
        public ResponseModel ManageSQLCommandHistory(GridOperationEnums operation, SQLCommandHistoryModel model)
        {
            ResponseModel response;
            AutoMapper.Mapper.CreateMap<SQLCommandHistoryModel, SQLCommandHistory>();
            SQLCommandHistory sqlCommandHistory;
            switch (operation)
            {
                case GridOperationEnums.Edit:
                    sqlCommandHistory = _sqlCommandHistoryRepository.GetById(model.Id);
                    sqlCommandHistory.Query = model.Query;
                    sqlCommandHistory.RecordOrder = model.RecordOrder;
                    sqlCommandHistory.RecordActive = model.RecordActive;
                    response = Update(sqlCommandHistory);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::SQLCommandHistorys:::Messages:::UpdateSuccessfully:::Update command successfully.")
                        : _localizedResourceServices.T("AdminModule:::SQLCommandHistorys:::Messages:::UpdateFailure:::Update command failed. Please try again later."));

                case GridOperationEnums.Add:
                    sqlCommandHistory = AutoMapper.Mapper.Map<SQLCommandHistoryModel, SQLCommandHistory>(model);
                    response = Insert(sqlCommandHistory);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::SQLCommandHistorys:::Messages:::CreateSuccessfully:::Create command successfully.")
                        : _localizedResourceServices.T("AdminModule:::SQLCommandHistorys:::Messages:::CreateFailure:::Create command failed. Please try again later."));

                case GridOperationEnums.Del:
                    response = Delete(model.Id);
                    return response.SetMessage(response.Success ?
                        _localizedResourceServices.T("AdminModule:::SQLCommandHistorys:::Messages:::DeleteSuccessfully:::Delete command successfully.")
                        : _localizedResourceServices.T("AdminModule:::SQLCommandHistorys:::Messages:::DeleteFailure:::Delete command failed. Please try again later."));
            }
            return new ResponseModel
            {
                Success = false,
                Message = _localizedResourceServices.T("AdminModule:::SQLCommandHistorys:::Messages:::ObjectNotFounded:::Command is not founded.")
            };
        }
예제 #3
0
        /// <summary>
        /// Save a SQL request into history for later use
        /// </summary>
        /// <param name="request"></param>
        public ResponseModel SaveCommand(SQLRequest request)
        {
            if (request.Query == null)
            {
                return new ResponseModel
                    {
                        Success = true
                    };
            }
            var last = GetLastCommand();
            if (last != null && last.Query == request.Query)
            {
                return new ResponseModel
                {
                    Success = true
                };
            }
            var history = new SQLCommandHistoryModel
            {
                Query = request.Query
            };
            var response = Insert(history);

            return response.SetMessage(response.Success ?
                _localizedResourceServices.T("AdminModule:::News:::Messages:::CreateSuccessfully:::Create news successfully.")
                : _localizedResourceServices.T("AdminModule:::News:::Messages:::CreateFailure:::Insert news failed. Please try again later."));
        }
예제 #4
0
 public ResponseModel Insert(SQLCommandHistoryModel historyModel)
 {
     var commandHistory = new SQLCommandHistory
         {
             Query = historyModel.Query,
             RecordActive = true
         };
     return Insert(commandHistory);
 }