29 changed files with 2582 additions and 1 deletions
@ -0,0 +1,17 @@ |
|||
using System; |
|||
|
|||
namespace Faster.Zheng.Winin.AppBusiness.DemoCar.Dtos; |
|||
|
|||
[Serializable] |
|||
public class CreateUpdateDemoCarDto |
|||
{ |
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
public string CarName { get; set; } |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
public string CarColor { get; set; } |
|||
} |
@ -0,0 +1,21 @@ |
|||
using System; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace Faster.Zheng.Winin.AppBusiness.DemoCar.Dtos; |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
[Serializable] |
|||
public class DemoCarDto : AuditedEntityDto<Guid> |
|||
{ |
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
public string CarName { get; set; } |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
public string CarColor { get; set; } |
|||
} |
@ -0,0 +1,21 @@ |
|||
using System; |
|||
using Faster.Zheng.Winin.AppBusiness.DemoCar.Dtos; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace Faster.Zheng.Winin.AppBusiness.DemoCar; |
|||
|
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
public interface IDemoCarAppService : |
|||
ICrudAppService< |
|||
DemoCarDto, |
|||
Guid, |
|||
PagedAndSortedResultRequestDto, |
|||
CreateUpdateDemoCarDto, |
|||
CreateUpdateDemoCarDto> |
|||
{ |
|||
|
|||
} |
@ -0,0 +1,30 @@ |
|||
using System; |
|||
using Faster.Zheng.Winin.AppBase; |
|||
using Faster.Zheng.Winin.Permissions; |
|||
using Faster.Zheng.Winin.AppBusiness.DemoCar.Dtos; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace Faster.Zheng.Winin.AppBusiness.DemoCar; |
|||
|
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
public class DemoCarAppService : ZbxBase<DemoCar, DemoCarDto, Guid, PagedAndSortedResultRequestDto, CreateUpdateDemoCarDto, CreateUpdateDemoCarDto>, |
|||
IDemoCarAppService |
|||
{ |
|||
protected override string GetPolicyName { get; set; } = WininPermissions.DemoCar.Default; |
|||
protected override string GetListPolicyName { get; set; } = WininPermissions.DemoCar.Default; |
|||
protected override string CreatePolicyName { get; set; } = WininPermissions.DemoCar.Create; |
|||
protected override string UpdatePolicyName { get; set; } = WininPermissions.DemoCar.Update; |
|||
protected override string DeletePolicyName { get; set; } = WininPermissions.DemoCar.Delete; |
|||
|
|||
private readonly IDemoCarRepository _repository; |
|||
|
|||
public DemoCarAppService(IDemoCarRepository repository) : base(repository) |
|||
{ |
|||
_repository = repository; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,17 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Entities.Auditing; |
|||
|
|||
namespace Faster.Zheng.Winin.AppBusiness.DemoCar |
|||
{ |
|||
public class DemoCar : AuditedAggregateRoot<Guid> |
|||
{ |
|||
public string CarName { get; set; } |
|||
|
|||
public string CarColor { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using Volo.Abp.Domain.Repositories; |
|||
|
|||
namespace Faster.Zheng.Winin.AppBusiness.DemoCar; |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
public interface IDemoCarRepository : IRepository<DemoCar, Guid> |
|||
{ |
|||
} |
@ -0,0 +1,22 @@ |
|||
using System.Linq; |
|||
using Microsoft.EntityFrameworkCore; |
|||
|
|||
namespace Faster.Zheng.Winin.AppBusiness.DemoCar; |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
public static class DemoCarEfCoreQueryableExtensions |
|||
{ |
|||
public static IQueryable<DemoCar> IncludeDetails(this IQueryable<DemoCar> queryable, bool include = true) |
|||
{ |
|||
if (!include) |
|||
{ |
|||
return queryable; |
|||
} |
|||
|
|||
return queryable |
|||
// .Include(x => x.xxx) // TODO: AbpHelper generated
|
|||
; |
|||
} |
|||
} |
@ -0,0 +1,20 @@ |
|||
using System; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Faster.Zheng.Winin.EntityFrameworkCore; |
|||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace Faster.Zheng.Winin.AppBusiness.DemoCar; |
|||
|
|||
public class DemoCarRepository : EfCoreRepository<WininDbContext, DemoCar, Guid>, IDemoCarRepository |
|||
{ |
|||
public DemoCarRepository(IDbContextProvider<WininDbContext> dbContextProvider) : base(dbContextProvider) |
|||
{ |
|||
} |
|||
|
|||
public override async Task<IQueryable<DemoCar>> WithDetailsAsync() |
|||
{ |
|||
return (await GetQueryableAsync()).IncludeDetails(); |
|||
} |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,42 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace Faster.Zheng.Winin.Migrations |
|||
{ |
|||
/// <inheritdoc />
|
|||
public partial class AddedDemoCarEntity : Migration |
|||
{ |
|||
/// <inheritdoc />
|
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "AppDemoCars", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
CarName = table.Column<string>(type: "nvarchar(max)", nullable: false), |
|||
CarColor = table.Column<string>(type: "nvarchar(max)", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AppDemoCars", x => x.Id); |
|||
}, |
|||
comment: ""); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "AppDemoCars"); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,18 @@ |
|||
@page |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal; |
|||
@using Faster.Zheng.Winin.Localization |
|||
@inject IHtmlLocalizer<WininResource> L |
|||
@model Faster.Zheng.Winin.Web.Pages.AppBusiness.DemoCar.DemoCar.CreateModalModel |
|||
@{ |
|||
Layout = null; |
|||
} |
|||
<abp-dynamic-form abp-model="ViewModel" data-ajaxForm="true" asp-page="CreateModal"> |
|||
<abp-modal> |
|||
<abp-modal-header title="@L["CreateDemoCar"].Value"></abp-modal-header> |
|||
<abp-modal-body> |
|||
<abp-form-content /> |
|||
</abp-modal-body> |
|||
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer> |
|||
</abp-modal> |
|||
</abp-dynamic-form> |
@ -0,0 +1,27 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Faster.Zheng.Winin.AppBusiness.DemoCar; |
|||
using Faster.Zheng.Winin.AppBusiness.DemoCar.Dtos; |
|||
using Faster.Zheng.Winin.Web.Pages.AppBusiness.DemoCar.DemoCar.ViewModels; |
|||
|
|||
namespace Faster.Zheng.Winin.Web.Pages.AppBusiness.DemoCar.DemoCar; |
|||
|
|||
public class CreateModalModel : WininPageModel |
|||
{ |
|||
[BindProperty] |
|||
public CreateEditDemoCarViewModel ViewModel { get; set; } |
|||
|
|||
private readonly IDemoCarAppService _service; |
|||
|
|||
public CreateModalModel(IDemoCarAppService service) |
|||
{ |
|||
_service = service; |
|||
} |
|||
|
|||
public virtual async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
var dto = ObjectMapper.Map<CreateEditDemoCarViewModel, CreateUpdateDemoCarDto>(ViewModel); |
|||
await _service.CreateAsync(dto); |
|||
return NoContent(); |
|||
} |
|||
} |
@ -0,0 +1,19 @@ |
|||
@page |
|||
@using Faster.Zheng.Winin.Localization |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal; |
|||
@inject IHtmlLocalizer<WininResource> L |
|||
@model Faster.Zheng.Winin.Web.Pages.AppBusiness.DemoCar.DemoCar.EditModalModel |
|||
@{ |
|||
Layout = null; |
|||
} |
|||
<abp-dynamic-form abp-model="ViewModel" data-ajaxForm="true" asp-page="EditModal"> |
|||
<abp-modal> |
|||
<abp-modal-header title="@L["EditDemoCar"].Value"></abp-modal-header> |
|||
<abp-modal-body> |
|||
<abp-input asp-for="Id" /> |
|||
<abp-form-content /> |
|||
</abp-modal-body> |
|||
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer> |
|||
</abp-modal> |
|||
</abp-dynamic-form> |
@ -0,0 +1,38 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Faster.Zheng.Winin.AppBusiness.DemoCar; |
|||
using Faster.Zheng.Winin.AppBusiness.DemoCar.Dtos; |
|||
using Faster.Zheng.Winin.Web.Pages.AppBusiness.DemoCar.DemoCar.ViewModels; |
|||
|
|||
namespace Faster.Zheng.Winin.Web.Pages.AppBusiness.DemoCar.DemoCar; |
|||
|
|||
public class EditModalModel : WininPageModel |
|||
{ |
|||
[HiddenInput] |
|||
[BindProperty(SupportsGet = true)] |
|||
public Guid Id { get; set; } |
|||
|
|||
[BindProperty] |
|||
public CreateEditDemoCarViewModel ViewModel { get; set; } |
|||
|
|||
private readonly IDemoCarAppService _service; |
|||
|
|||
public EditModalModel(IDemoCarAppService service) |
|||
{ |
|||
_service = service; |
|||
} |
|||
|
|||
public virtual async Task OnGetAsync() |
|||
{ |
|||
var dto = await _service.GetAsync(Id); |
|||
ViewModel = ObjectMapper.Map<DemoCarDto, CreateEditDemoCarViewModel>(dto); |
|||
} |
|||
|
|||
public virtual async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
var dto = ObjectMapper.Map<CreateEditDemoCarViewModel, CreateUpdateDemoCarDto>(ViewModel); |
|||
await _service.UpdateAsync(Id, dto); |
|||
return NoContent(); |
|||
} |
|||
} |
@ -0,0 +1,48 @@ |
|||
@page |
|||
@using Faster.Zheng.Winin.Permissions |
|||
@using Microsoft.AspNetCore.Authorization |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Layout |
|||
@using Faster.Zheng.Winin.Web.Pages.AppBusiness.DemoCar.DemoCar |
|||
@using Faster.Zheng.Winin.Localization |
|||
@using Faster.Zheng.Winin.Web.Menus |
|||
@model IndexModel |
|||
@inject IPageLayout PageLayout |
|||
@inject IHtmlLocalizer<WininResource> L |
|||
@inject IAuthorizationService Authorization |
|||
@{ |
|||
PageLayout.Content.Title = L["DemoCar"].Value; |
|||
PageLayout.Content.BreadCrumb.Add(L["Menu:DemoCar"].Value); |
|||
PageLayout.Content.MenuItemName = WininMenus.DemoCar; |
|||
} |
|||
|
|||
@section scripts |
|||
{ |
|||
<abp-script src="/Pages/AppBusiness/DemoCar/DemoCar/index.js" /> |
|||
} |
|||
@section styles |
|||
{ |
|||
<abp-style src="/Pages/AppBusiness/DemoCar/DemoCar/index.css"/> |
|||
} |
|||
|
|||
<abp-card> |
|||
<abp-card-header> |
|||
<abp-row> |
|||
<abp-column size-md="_6"> |
|||
<abp-card-title>@L["DemoCar"]</abp-card-title> |
|||
</abp-column> |
|||
<abp-column size-md="_6" class="text-end"> |
|||
@if (await Authorization.IsGrantedAsync(WininPermissions.DemoCar.Create)) |
|||
{ |
|||
<abp-button id="NewDemoCarButton" |
|||
text="@L["CreateDemoCar"].Value" |
|||
icon="plus" |
|||
button-type="Primary" /> |
|||
} |
|||
</abp-column> |
|||
</abp-row> |
|||
</abp-card-header> |
|||
<abp-card-body> |
|||
<abp-table striped-rows="true" id="DemoCarTable" class="nowrap"/> |
|||
</abp-card-body> |
|||
</abp-card> |
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Faster.Zheng.Winin.Web.Pages.AppBusiness.DemoCar.DemoCar; |
|||
|
|||
public class IndexModel : WininPageModel |
|||
{ |
|||
|
|||
public virtual async Task OnGetAsync() |
|||
{ |
|||
await Task.CompletedTask; |
|||
} |
|||
} |
|||
|
@ -0,0 +1,13 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Faster.Zheng.Winin.Web.Pages.AppBusiness.DemoCar.DemoCar.ViewModels; |
|||
|
|||
public class CreateEditDemoCarViewModel |
|||
{ |
|||
[Display(Name = "DemoCarCarName")] |
|||
public string CarName { get; set; } |
|||
|
|||
[Display(Name = "DemoCarCarColor")] |
|||
public string CarColor { get; set; } |
|||
} |
@ -0,0 +1,70 @@ |
|||
$(function () { |
|||
|
|||
var l = abp.localization.getResource('Winin'); |
|||
|
|||
var service = faster.zheng.winin.appBusiness.demoCar.demoCar; |
|||
var createModal = new abp.ModalManager(abp.appPath + 'AppBusiness/DemoCar/DemoCar/CreateModal'); |
|||
var editModal = new abp.ModalManager(abp.appPath + 'AppBusiness/DemoCar/DemoCar/EditModal'); |
|||
|
|||
var dataTable = $('#DemoCarTable').DataTable(abp.libs.datatables.normalizeConfiguration({ |
|||
processing: true, |
|||
serverSide: true, |
|||
paging: true, |
|||
searching: false, |
|||
autoWidth: false, |
|||
scrollCollapse: true, |
|||
order: [[0, "asc"]], |
|||
ajax: abp.libs.datatables.createAjax(service.getList), |
|||
columnDefs: [ |
|||
{ |
|||
rowAction: { |
|||
items: |
|||
[ |
|||
{ |
|||
text: l('Edit'), |
|||
visible: abp.auth.isGranted('Winin.DemoCar.Update'), |
|||
action: function (data) { |
|||
editModal.open({ id: data.record.id }); |
|||
} |
|||
}, |
|||
{ |
|||
text: l('Delete'), |
|||
visible: abp.auth.isGranted('Winin.DemoCar.Delete'), |
|||
confirmMessage: function (data) { |
|||
return l('DemoCarDeletionConfirmationMessage', data.record.id); |
|||
}, |
|||
action: function (data) { |
|||
service.delete(data.record.id) |
|||
.then(function () { |
|||
abp.notify.info(l('SuccessfullyDeleted')); |
|||
dataTable.ajax.reload(); |
|||
}); |
|||
} |
|||
} |
|||
] |
|||
} |
|||
}, |
|||
{ |
|||
title: l('DemoCarCarName'), |
|||
data: "carName" |
|||
}, |
|||
{ |
|||
title: l('DemoCarCarColor'), |
|||
data: "carColor" |
|||
}, |
|||
] |
|||
})); |
|||
|
|||
createModal.onResult(function () { |
|||
dataTable.ajax.reload(); |
|||
}); |
|||
|
|||
editModal.onResult(function () { |
|||
dataTable.ajax.reload(); |
|||
}); |
|||
|
|||
$('#NewDemoCarButton').click(function (e) { |
|||
e.preventDefault(); |
|||
createModal.open(); |
|||
}); |
|||
}); |
Loading…
Reference in new issue