标签:orm als 控制 序列化 ima 技术分享 type 方法 添加
<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 class="col-xs-6 text-right"> <button id="CreateNewCategoryButton" class="btn btn-primary blue"><i class="fa fa-plus"></i>添加分类</button> </div> </div>
@using MyCompanyName.AbpZeroTemplate.Web.Areas.Mpa.Models.Common.Modals @Html.Partial("~/Areas/Mpa/Views/Common/Modals/_ModalHeader.cshtml", new ModalHeaderViewModel("添加分类")) <div class="modal-body"> <form name="CategoryForm"> <div class="form-group form-md-line-input form-md-floating-label"> <input class="form-control" type="text" name="Name"> <label>名称</label> </div> </form> </div> @Html.Partial("~/Areas/Mpa/Views/Common/Modals/_ModalFooterWithSaveAndCancel.cshtml")
(function ($) { app.modals.CreateCategoryModal = function () { var _categoryService = abp.services.app.category; var _$categoryForm = null; var _modalManager; this.init = function (modalManager) { _modalManager = modalManager; //取出Form表单 _$categoryForm = _modalManager.getModal().find(‘form[name=CategoryForm]‘); }; this.save = function () { //序列化参数 var category = _$categoryForm.serializeFormToObject(); _modalManager.setBusy(true); _categoryService.createCategory( category ).done(function () { abp.notify.info(app.localize(‘SavedSuccessfully‘)); _modalManager.close(); abp.event.trigger(‘app.createCategoryModalSaved‘); }).always(function () { _modalManager.setBusy(false); }); }; }; })(jQuery);
void CreateCategory(CreateCategoryInput input);
public void CreateCategory(CreateCategoryInput input) { _categoryRepository.Insert(new Category() { Name = input.Name }); }
public class CreateCategoryInput:EntityDto,IInputDto { public string Name { get; set; } }
... var _categoryService = abp.services.app.category; var _createModal = new app.ModalManager({ viewUrl: abp.appPath + ‘Mpa/Category/CreateModal‘,//加载视图 scriptUrl: abp.appPath + ‘Areas/Mpa/Views/Category/_CreateModal.js‘,//加载对应js modalClass: ‘CreateCategoryModal‘ }); ... //页面加载完执行 getCategories(); //添加点击事件 $(‘#CreateNewCategoryButton‘).click(function () { _createModal.open(); }); //事件注册 abp.event.on(‘app.createCategoryModalSaved‘, function () { getCategories(true); });
public ActionResult CreateModal() { return PartialView("_CreateModal"); }
ASP.NET Zero--10.一个例子(3)商品分类管理-新建
标签:orm als 控制 序列化 ima 技术分享 type 方法 添加
原文地址:http://www.cnblogs.com/shensigzs/p/6288785.html