abp(net core)+easyui+efcore实现仓储管理系统——ABP整体介绍(一)html
abp(net core)+easyui+efcore实现仓储管理系统——解决方案介绍(二)前端
abp(net core)+easyui+efcore实现仓储管理系统——领域层建立实体(三)json
abp(net core)+easyui+efcore实现仓储管理系统——定义仓储并实现 (四)浏览器
abp(net core)+easyui+efcore实现仓储管理系统——建立应用服务(五)app
abp(net core)+easyui+efcore实现仓储管理系统——展示层实现增删改查之控制器(六)框架
abp(net core)+easyui+efcore实现仓储管理系统——展示层实现增删改查之列表视图(七)post
abp(net core)+easyui+efcore实现仓储管理系统——展示层实现增删改查之增删改视图(八)测试
abp(net core)+easyui+efcore实现仓储管理系统——展示层实现增删改查之菜单与测试(九)ui
abp(net core)+easyui+efcore实现仓储管理系统——多语言(十)spa
abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十一)
abp(net core)+easyui+efcore实现仓储管理系统——菜单-上 (十六)
abp(net core)+easyui+efcore实现仓储管理系统——EasyUI前端页面框架 (十八)
abp(net core)+easyui+efcore实现仓储管理系统——EasyUI之货物管理一 (十九)
abp(net core)+easyui+efcore实现仓储管理系统——EasyUI之货物管理二 (二十)
在上一篇 abp(net core)+easyui+efcore实现仓储管理系统——EasyUI之货物管理五 (二十三) 文章中,咱们修正了一些BUG,让货物信息管理的前端与后台功能基本实现了咱们所要。如今咱们运行起应用程序看看新增功能。
十5、新增货物信息
继续来实现咱们的货物信息管理功能,以前咱们已经实现了列表功能,如今咱们来实现货物信息的增长功能。
1. 在Visual Studio 2017的“解决方案资源管理器”中,右键单击在领域层“ABP.TPLMS.Web.Core”项目中的Controller目录。 找到TPLMSControllerBase文件,添加一个新的方法JsonEasyUIResult。此方法用来实现当咱们完成了增长货物信息以后,返回给前端相关信息。代码以下。
protected dynamic JsonEasyUIResult(int id,string result) { string strId = string.Empty; if (id>0) { strId = id.ToString(); } var obj = new { result = result, Id = strId }; var json = ABP.TPLMS.Helpers.JsonHelper.Instance.Serialize(obj); return json; }
public ActionResult Add(CargoDto createDto) { var json = string.Empty; string result = "NO"; if (createDto == null) { json = JsonEasyUIResult(0, result); return Content(json); } try { var cargo = ObjectMapper.Map<CreateUpdateCargoDto>(createDto); // TODO: Add logic here var obj = _cargoAppService.Create(cargo); int id = obj.GetAwaiter().GetResult().Id; if (obj != null) { json = JsonEasyUIResult(id, "OK"); } else { json = JsonEasyUIResult(0,result); } } catch { } return Content(json); }
3.在Visual Studio 2017中按F5运行应用程序。
4.在浏览器中的地址栏中输入“http://localhost:5000/”,而后输入管理员用户名进行登陆。
5.在主界面的菜单中,选择“Business->货物管理”菜单项,浏览器中呈现一个货物信息列表与四个按钮。以下图。关于菜单的生成能够参见文章(abp(net core)+easyui+efcore实现仓储管理系统——菜单-上 (十六) 与 abp(net core)+easyui+efcore实现仓储管理系统——菜单-下(十七) )。
6.新增货物:点击“添加”按钮,弹出一个“添加货物”的操做界面,以下图中所示。
7.在输入相应的货物信息以后,点击“保存”按钮 。在弹出的确认对话框中点击“肯定”按钮。在弹出的“保存成功”确认对话框中点击“肯定”按钮。
8.而后系统就没有任何反应,没有弹出任何提示信息,查询数据也没有发现添加新数据。咱们在浏览器中按F12,而后发现原来报错了。以下图。
具体错误信息以下:
An unhandled exception occurred while processing the request.
AbpValidationException: Method arguments are not valid! See ValidationErrors for details.
Abp.Runtime.Validation.Interception.MethodInvocationValidator.ThrowValidationError() in MethodInvocationValidator.cs, line 118
9.原来是ABP的一个校验异常。ABP的两个特性EnableValidation和DisableValidation 用来控制validation。咱们在Add方法上面添加两个特性[HttpPost]与[DisableValidation]。
[HttpPost] [DisableValidation] public ActionResult Add(CargoDto createDto) {… 代码见第2步。}
10.从新从第3步到第7步。此次保存成功。见下图。