ASP.NET Zero--9.一个例子(2)商品分类管理-列表
1.创建实体类
参考:http://www.cnblogs.com/farb/p/4923137.html
public class Category:Entity
{
/// <summary>
/// 分类名称
/// </summary>
public string Name { get; set; } }
2.DbContext
参考:http://www.cnblogs.com/farb/p/4925290.html

3.创建数据库迁移
参考:http://www.cnblogs.com/farb/p/4925864.html



4.定义、实现仓储
参考:http://www.cnblogs.com/farb/p/4926493.html
http://www.cnblogs.com/farb/p/ABPPractice_ImplementRepository.html
public interface ICategoryRepository: IRepository<Category>
{ }
public class CategoryRepository: AbpZeroTemplateRepositoryBase<Category>,ICategoryRepository
{
public CategoryRepository(IDbContextProvider<AbpZeroTemplateDbContext> dbContextProvider) : base(dbContextProvider)
{
}
}
5.构建服务
参考:http://www.cnblogs.com/farb/p/4930968.html

public class CategoryOutput : IOutputDto
{
public int Id { get; set; }
public string Name { get; set; }
} public class GetCategoriesOutput : IOutputDto
{
public List<CategoryOutput> Items { get; set; }
}
public interface ICategoryAppService : IApplicationService
{
PagedResultOutput<CategoryOutput> GetCategories();
}
public class CategoryAppService : AbpZeroTemplateAppServiceBase, ICategoryAppService
{
private readonly ICategoryRepository _categoryRepository;
public CategoryAppService(ICategoryRepository categoryRepository)
{
_categoryRepository = categoryRepository;
}
public PagedResultOutput<CategoryOutput> GetCategories()
{
//创建映射
Mapper.CreateMap<Category, CategoryOutput>();
var result=_categoryRepository.GetAllList();
int totalCount = result.Count;
return new PagedResultOutput<CategoryOutput>(
totalCount,
Mapper.Map<List<CategoryOutput>>(result)
);
}
}
6.创建控制器
参考:http://www.cnblogs.com/farb/p/BuildDynamicWebAPI.html
public class CategoryController : AbpZeroTemplateControllerBase
{
// GET: Mpa/Category
public ActionResult Index()
{
return View();
}
}
7.创建视图
@using Abp.Web.Mvc.Extensions
@using MyCompanyName.AbpZeroTemplate.Web.Navigation
@{
ViewBag.CurrentPageName = PageNames.App.Common.Category;//作用就是选中菜单时会高亮
}
@section Scripts
{
@Html.IncludeScript("~/Areas/Mpa/Views/Category/Index.js")
}
<div class="row margin-bottom-5">
<div class="col-xs-6">
<div class="page-head">
<div class="page-title">
<h1>
<span>分类</span> <small>@L("CategoryManager")</small>
</h1>
</div>
</div>
</div>
</div>
<div class="portlet light">
<div class="portlet-body">
<div>
<div id="CategoriesTable"></div>
</div>
</div>
</div>
8.创建js文件
(function () {
$(function () {
var _$categoriesTable = $('#CategoriesTable');
var _categoryService = abp.services.app.category;
_$categoriesTable.jtable({
title: app.localize('CategoryManager'),//标题
paging: true,//启用分页
sorting: true,//启用排序
multiSorting: true,//启用多列排序
actions: {
listAction: {
method: _categoryService.getCategories//获取列表方法
}
},
fields: {
id: {
key: true,
list: false
},
actions: {
title: app.localize('Actions'),//操作列
width: '15%',
sorting: false
},
name: {
title: app.localize('Name'),
width: '20%'
}
}
});
//获取列表
function getCategories(reload) {
if (reload) {
_$categoriesTable.jtable('reload');
} else {
_$categoriesTable.jtable('load');
}
}
//页面加载完执行
getCategories();
});
})();
9.生成项目

ASP.NET Zero--9.一个例子(2)商品分类管理-列表的更多相关文章
- [asp.net core]SignalR一个例子
摘要 在一个后台管理的页面想实时监控一些操作的数据,想到用signalR. 一个例子 asp.net core+signalR 使用Nuget安装包:Microsoft.AspNetCore.Sign ...
- ASP.NET Zero--8.一个例子(1)菜单添加
以一个商品分类管理功能来编写,代码尽量简单易懂.从一个实体开始,一直到权限控制,由浅到深一步步对功能进行完善. 1.打开语言文件 [..\MyCompanyName.AbpZeroTemplate.C ...
- 这算是ASP.NET MVC的一个大BUG吗?
这是昨天一个同事遇到的问题,我觉得这是一个蛮大的问题,而且不像是ASP.NET MVC的设计者有意为之,换言之,这可能是ASP.NET MVC的一个Bug(不过也有可能是保持原始请求数据而作的妥协). ...
- 一个例子读懂 JS 异步编程: Callback / Promise / Generator / Async
JS异步编程实践理解 回顾JS异步编程方法的发展,主要有以下几种方式: Callback Promise Generator Async 需求 显示购物车商品列表的页面,用户可以勾选想要删除商品(单选 ...
- spring笔记--使用springAPI以及自定义类 实现AOP的一个例子
Spring的另一个重要思想是AOP,面向切面的编程,它提供了一种机制,可以在执行业务前后执行另外的代码,Servlet中的Filter就是一种AOP思想的体现,下面通过一个例子来感受一下. 假设我们 ...
- ReCap 360 photo照片建模技术的又一个例子
这是我做的又一个利用Autodesk ReCap 360 照片建模技术做的一个例子.你可以下载模型自己把玩,或者下载原始照片自己试一试. 拍摄工具: 小米手机 照片数量:约120张 后期处理工具: p ...
- 从一个例子中体会React的基本面
[起初的准备工作] npm init npm install --save react react-dom npm install --save-dev html-webpack-plugin web ...
- 用thinkphp写的一个例子:抓取网站的内容并且保存到本地
我需要写这么一个例子,到电子课本网下载一本电子书. 电子课本网的电子书,是把书的每一页当成一个图片,然后一本书就是有很多张图片,我需要批量的进行下载图片操作. 下面是代码部分: public func ...
- Erlang 程序引发共享内存 bug 的一个例子
虽然 Erlang 的广告说得非常好,functional.share-nothing.消息传递,blah blah 的,好像用 Erlang 写并发程序就高枕无忧了,但是由于 Erlang 信奉高度 ...
随机推荐
- POJ 3624 Charm Bracelet 背包问题的解决方案
最简单的背包问题,标题应该是除了背包测试中心:您无法打开二维数组.我还没有开的二维.光看数据是不可能的. 太大. 有两种方法来提高全省内存DP: 1 所谓卷的阵列 2 反向表 久没做背包DP,突然认为 ...
- DDD分层架构之领域实体(验证篇)
DDD分层架构之领域实体(验证篇) 在应用程序框架实战十四:DDD分层架构之领域实体(基础篇)一文中,我介绍了领域实体的基础,包括标识.相等性比较.输出实体状态等.本文将介绍领域实体的一个核心内容—— ...
- ubuntu忘记密码,无法sudo的解决方法
想要安装一个sublime Text Editor,发现需要root权限,而且sudo用户的密码输进去没有作用!@ubuntu 14.04 LTS 这个时候怎么办呢? 打开终端,在终端中使用 sudo ...
- css 初始化
html,body,h1,h2,h3,h4,h5,h6,div,dl,dt,dd,ul,ol,li,p,blockquote,pre,hr,figure,table,caption,th,td,for ...
- 关于 MVCC 的基础
作为第一篇对 MVCC 的学习材料,以下内容翻译自 Wikipedia. 1. 什么是MVCC 1.1 基础概念 MVCC,Multi-Version Concurrency Control,多版本并 ...
- KMP算法详解-- 转自Matrix67
6 7 8 9 -- A = a b a b 6 7 7 8 9 -- A = a b a b a 5 6 7 8 9 -- A = a b a b a b 6 7 ...
- MySQL中char和varchar有啥区别?优缺点是啥?
在mysql教程中char与varchar的区别呢,都是用来存储字符串的,只是他们的保存方式不一样罢了,char有固定的长度,而varchar属于可变长的字符类型. char与varchar的区别 c ...
- Hadoop 从URL中读取数据
package com.hadoop; import java.io.IOException; import java.io.InputStream; import java.net.URL; imp ...
- PHP GD 库 缩略图 添加水印
class cls_image { var $error_no = 0; var $error_msg = ''; //var $images_dir = IMAGE_DIR; //var $data ...
- 在html中使用javascript显示本地图片的
<html> <head> <script type="text/javascript"> function getFullPath(obj){ ...