欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

ABP开发手记10 - 展示层实现增删改查-控制器

程序员文章站 2022-06-03 17:00:33
点这里进入ABP开发手记目录 创建视图模型 在展示层(即JD.CRS.Web.Mvc)的Controllers下新建一个控制器CourseController.cs 1 using Abp.Application.Services.Dto; 2 using Abp.AspNetCore.Mvc.Au ......

点这里进入abp开发手记目录 

创建视图模型

在展示层(即jd.crs.web.mvc)的controllers下新建一个控制器coursecontroller.cs

 1 using abp.application.services.dto;
 2 using abp.aspnetcore.mvc.authorization;
 3 using jd.crs.authorization;
 4 using jd.crs.controllers;
 5 using jd.crs.course;
 6 using jd.crs.web.models.course;
 7 using microsoft.aspnetcore.mvc;
 8 using system.threading.tasks;
 9 
10 namespace jd.crs.web.controllers
11 {
12     [abpmvcauthorize(permissionnames.pages_course)]
13     public class coursecontroller : crscontrollerbase
14     {
15         private readonly icourseappservice _courseappservice;
16         const int maxnum = 10;
17         public coursecontroller(icourseappservice courseappservice)
18         {
19             _courseappservice = courseappservice;
20         }
21         // get: /<controller>/
22         public async task<actionresult> index()
23         {
24             var courses = (await _courseappservice.getall(new pagedresultrequestdto { maxresultcount = maxnum })).items;
25             // paging not implemented yet
26             var model = new courselistviewmodel
27             {
28                 courses = courses
29             };
30             return view(model);
31         }
32 
33         public async task<actionresult> editcoursemodal(int courseid)
34         {
35             var course = await _courseappservice.get(new entitydto<int>(courseid));
36             var model = new editcoursemodalviewmodel
37             {
38                 course = course
39             };
40             return view("_editcoursemodal", model);
41         }
42     }
43 }