(资料图片)
1.在Visual Studio 2022的解决方案资源管理器中,选中“ABP.TPLMS.Web.Mvc”项目,然后单击鼠标右键,在弹出菜单中选中“设为启动项目”。按F5运行应用程序。
2.在浏览器将呈现登录页面,然后输入管理员用户名进行登录。浏览器跳转到首页面。如下图。
3.在主界面的菜单中,选择“Business->供应商管理”菜单项,浏览器立即报了一个错误。如下图。
4.这是AutoMapper.Mapper方法造成的。这是由于在升级的时候,AutoMapper也升级了。由于NET模型映射器AutoMapper 9.0之后,官方宣称不再支持静态方法调用,之前直接升级编译报错无法使用。我简单的在代码的构造函数中使用注入方式,注入Mapper。现在实际运行时,发现这种方式,如果没有在startup.cs代码中预先注册,是无法使用的。原先的代码如下:
using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using Abp.Application.Services.Dto;using Abp.AspNetCore.Mvc.Authorization;using Abp.Auditing;using Abp.Runtime.Validation;using ABP.TPLMS.Controllers;using ABP.TPLMS.Suppliers;using ABP.TPLMS.Suppliers.Dto;using ABP.TPLMS.Web.Models.Supplier;using Microsoft.AspNetCore.Mvc;using Microsoft.EntityFrameworkCore; // For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 namespace ABP.TPLMS.Web.Controllers{ [AbpMvcAuthorize] [Audited] public class SupplierController : TPLMSControllerBase { const int MaxNum= 10; // GET: // [DisableAuditing] public async Task Index() { SupplierDto cuModule=null; var module = (await _supplierAppService.GetAllAsync(new PagedSupplierResultRequestDto { MaxResultCount = MaxNum })).Items; // Paging not implemented yet if (module.Count>0) { cuModule = module.First(); } var model = new SupplierListViewModel { Supplier = cuModule, Suppliers=module }; return View(model); } private readonly ISupplierAppService _supplierAppService; AutoMapper.Mapper m_map; public SupplierController(ISupplierAppService supplierAppService,AutoMapper.Mapper map) { _supplierAppService = supplierAppService; m_map = map; } public async Task EditSupplierModal(int supplierId) { var module = await _supplierAppService.GetAsync(new EntityDto (supplierId)); CreateUpdateSupplierDto cuSupplier = m_map.Map (module); var model = new EditSupplierModalViewModel { Supplier = cuSupplier }; return View("_EditSupplierModal", model); } }}
5.幸好发现有一个ABP.ObjectMapper.Map方法可以使用,我们将代码修改为:
using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using Abp.Application.Services.Dto;using Abp.AspNetCore.Mvc.Authorization;using Abp.Auditing;using Abp.Runtime.Validation;using ABP.TPLMS.Controllers;using ABP.TPLMS.Suppliers;using ABP.TPLMS.Suppliers.Dto;using ABP.TPLMS.Web.Models.Supplier;using Microsoft.AspNetCore.Mvc;using Microsoft.EntityFrameworkCore; // For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 namespace ABP.TPLMS.Web.Controllers{ [AbpMvcAuthorize] [Audited] public class SupplierController : TPLMSControllerBase { const int MaxNum= 10; // GET: // [DisableAuditing] public async Task Index() { SupplierDto cuModule=null; var module = (await _supplierAppService.GetAllAsync(new PagedSupplierResultRequestDto { MaxResultCount = MaxNum })).Items; // Paging not implemented yet if (module.Count>0) { cuModule = module.First(); } var model = new SupplierListViewModel { Supplier = cuModule, Suppliers=module }; return View(model); } private readonly ISupplierAppService _supplierAppService; public SupplierController(ISupplierAppService supplierAppService) { _supplierAppService = supplierAppService; } public async Task EditSupplierModal(int supplierId) { var module = await _supplierAppService.GetAsync(new EntityDto (supplierId)); CreateUpdateSupplierDto cuSupplier = ObjectMapper.Map (module); var model = new EditSupplierModalViewModel { Supplier = cuSupplier }; return View("_EditSupplierModal", model); }}}
6.在Visual Studio 2022的解决方案资源管理器,按F5运行应用程序。
7.在浏览器将呈现登录页面,然后输入管理员用户名进行登录。浏览器跳转到首页面,在主界面的菜单中,选择“Business->供应商管理”菜单项,浏览器中呈现一个供应商信息列表页面,我们发现此页面的顶部与右边的菜单部分缺失css,样式不好看。如下图。
8. 在Visual Studio 2017的“解决方案资源管理器”中,右键单击在领域层“ABP.TPLMS.Web.Mvc”项目中的Views\Supplier目录。 找到Index.cshmtl文件,修改顶部的代码与按钮的代码。具体代码如下:
@using ABP.TPLMS.Web.Startup@model ABP.TPLMS.Web.Models.Supplier.SupplierListViewModel @{ ViewData["Title"] = PageNames.Supplier;}@section scripts { <script src="~/view-resources/Views/Supplier/Index.js" asp-append-version="true"></script>}
@foreach (var item in Model.Suppliers) { @Html.DisplayNameFor(model => model.Supplier.Code) @Html.DisplayNameFor(model => model.Supplier.Name) @Html.DisplayNameFor(model => model.Supplier.LinkName) @Html.DisplayNameFor(model => model.Supplier.Mobile) @Html.DisplayNameFor(model => model.Supplier.Address) @Html.DisplayNameFor(model => model.Supplier.Tel) @Html.DisplayNameFor(model => model.Supplier.Status) } @Html.DisplayFor(modelItem => item.Code) @Html.DisplayFor(modelItem => item.Name) @Html.DisplayFor(modelItem => item.LinkName) @Html.DisplayFor(modelItem => item.Mobile) @Html.DisplayFor(modelItem => item.Address) @Html.DisplayFor(modelItem => item.Tel) @Html.DisplayFor(modelItem => item.Status) @L("Edit") @L("Delete")
下一篇:最后一页
X 关闭
-
abp(net core)+easyui+efcore实现仓储管理系统——供应商管理升级之上(六十三)
有了前面两篇关于升级的文章,组织管理和模块管理,并在升级过程中解决了一些升级中出现的问题。我们对供应
-
民事上诉状范文_二审民事上诉状范文
1、二审民事上诉状怎么写一些法律问题是人民群众所不了解的,接下来华律小编就二审民事上诉状的相关知识做
-
曹原_对于曹原简单介绍-全球观焦点
1、曹原。2、生于1991年陕西省榆林市。3、画家。文章到此就分享结束,希望对大家有所帮助。
-
启东市气象台发布雷暴大风黄色预警【Ⅲ级/较大】【2023-05-04】-天天滚动
启东市气象台2023年05月04日17时55分发布雷暴大风黄色预警信号:预计未来6小时内我市各镇(区、街道)将出
-
克里姆林宫:对无人机袭击克里姆林宫事件的回应会经过周密考虑 世界实时
俄罗斯总统新闻秘书佩斯科夫4日表示,俄罗斯对无人机袭击克里姆林宫的回应措施会经过周密考虑并符合俄罗斯