Пример #1
0
        public ActionResult Create(ActionViewModel model)
        {
            ServiceResult result = new ServiceResult();
            if (ModelState.IsValid)
            {
                try
                {
                    ActionService.Create(model);
                    result.Message = "添加操作成功!";
                    LogHelper.WriteLog("添加操作成功");
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("添加操作错误", ex);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");

            }

            return Json(result);
        }
Пример #2
0
        public ActionResult Create(ControllerViewModel model)
        {
            ServiceResult result = new ServiceResult();
            TempData["Service_Result"] = result;
            if (ModelState.IsValid)
            {
                try
                {
                    ControllerService.Create(model);
                    result.Message = "添加控制器成功!";
                    LogHelper.WriteLog("添加控制器成功");
                }
                catch (Exception ex)
                {
                    result.Message = Utilities.GetInnerMostException(ex);
                    result.AddServiceError(result.Message);
                    LogHelper.WriteLog("添加控制器错误", ex);
                }
            }
            else
            {
                result.Message = "请检查表单是否填写完整!";
                result.AddServiceError("请检查表单是否填写完整!");

            }
            return Json(result);
        }
Пример #3
0
 public ActionResult Delete(int ID)
 {
     ServiceResult result = new ServiceResult();
     var entity = ActionService.Find(ID);
     try
     {
         ActionService.Delete(entity);
         result.Message = "删除操作成功!";
         LogHelper.WriteLog("删除操作成功");
     }
     catch (Exception ex)
     {
         result.Message = Utilities.GetInnerMostException(ex);
         result.AddServiceError(result.Message);
         LogHelper.WriteLog("删除操作错误", ex);
     }
     return Json(result);
 }