Пример #1
0
        public IActionResult EditDictionary(dictionaryModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                ShowTipMessage(LayerIconType.Sigh, "", false);
                return(View(viewModel));
            }

            try
            {
                //事务操作
                _database.RunInTransaction(() =>
                {
                    //更新信息,不更新pid和type
                    _database.UpdateSet <dictionaryModel>(
                        new
                    {
                        viewModel.id,
                        viewModel.name,
                        viewModel.val,
                        viewModel.code,
                        viewModel.remark,
                        viewModel.isystem,
                        viewModel.modifyon
                    });

                    //更新子类类型
                    _database.UpdateSet <dictionaryModel>(new { type = viewModel.name },
                                                          Predicates.Field <dictionaryModel>(f => f.pid, Operator.Eq, viewModel.id));
                });
                ShowTipMessage(LayerIconType.Success);
                _cache.Remove(_cacheDictList);
            }
            catch
            {
                ShowTipMessage(LayerIconType.Erro, "", false);
            }
            return(View(viewModel));
        }
Пример #2
0
        public IActionResult AddDictionary(dictionaryModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                ShowTipMessage(LayerIconType.Sigh, "", false);
                return(View(viewModel));
            }
            if (string.IsNullOrEmpty(viewModel.type))
            {
                viewModel.pid = 0;
            }
            var result = _database.Insert <dictionaryModel>(viewModel);

            if (result > 0)
            {
                ShowTipMessage(LayerIconType.Success, "", true);
                _cache.Remove(_cacheDictList);
            }
            else
            {
                ShowTipMessage(LayerIconType.Erro, "", false);
            }
            return(View(viewModel));
        }