mirror of https://github.com/abpframework/eventhub
14 changed files with 2478 additions and 23 deletions
@ -0,0 +1,11 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
|
||||
|
namespace EventHub.Organizations |
||||
|
{ |
||||
|
public interface IOrganizationAppService : IApplicationService |
||||
|
{ |
||||
|
Task<PagedResultDto<OrganizationInListDto>> GetListAsync(PagedResultRequestDto input); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
using System; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace EventHub.Organizations |
||||
|
{ |
||||
|
public class OrganizationInListDto : EntityDto<Guid> |
||||
|
{ |
||||
|
public string Name { get; set; } |
||||
|
|
||||
|
public string DisplayName { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Domain.Repositories; |
||||
|
|
||||
|
namespace EventHub.Organizations |
||||
|
{ |
||||
|
public class OrganizationAppService : EventHubAppService, IOrganizationAppService |
||||
|
{ |
||||
|
private readonly IRepository<Organization, Guid> _organizationRepository; |
||||
|
|
||||
|
public OrganizationAppService(IRepository<Organization, Guid> organizationRepository) |
||||
|
{ |
||||
|
_organizationRepository = organizationRepository; |
||||
|
} |
||||
|
|
||||
|
public async Task<PagedResultDto<OrganizationInListDto>> GetListAsync(PagedResultRequestDto input) |
||||
|
{ |
||||
|
var organizationCount = await _organizationRepository.GetCountAsync(); |
||||
|
var organizations = await _organizationRepository.GetPagedListAsync( |
||||
|
input.SkipCount, |
||||
|
input.MaxResultCount, |
||||
|
nameof(Organization.DisplayName) |
||||
|
); |
||||
|
|
||||
|
return new PagedResultDto<OrganizationInListDto>( |
||||
|
organizationCount, |
||||
|
ObjectMapper.Map<List<Organization>, List<OrganizationInListDto>>(organizations) |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
File diff suppressed because it is too large
@ -0,0 +1,50 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
namespace EventHub.Migrations |
||||
|
{ |
||||
|
public partial class Added_Organizations : Migration |
||||
|
{ |
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppOrganizations", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
||||
|
OwnerUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
||||
|
Name = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: false), |
||||
|
DisplayName = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false), |
||||
|
Description = table.Column<string>(type: "nvarchar(max)", nullable: true), |
||||
|
Website = table.Column<string>(type: "nvarchar(max)", nullable: true), |
||||
|
TwitterUsername = table.Column<string>(type: "nvarchar(max)", nullable: true), |
||||
|
GitHubUsername = table.Column<string>(type: "nvarchar(max)", nullable: true), |
||||
|
FacebookUsername = table.Column<string>(type: "nvarchar(max)", nullable: true), |
||||
|
InstagramUsername = table.Column<string>(type: "nvarchar(max)", nullable: true), |
||||
|
MediumUsername = table.Column<string>(type: "nvarchar(max)", nullable: true), |
||||
|
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppOrganizations", x => x.Id); |
||||
|
}); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppOrganizations_DisplayName", |
||||
|
table: "AppOrganizations", |
||||
|
column: "DisplayName"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppOrganizations_Name", |
||||
|
table: "AppOrganizations", |
||||
|
column: "Name"); |
||||
|
} |
||||
|
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppOrganizations"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
@page "/organizations" |
||||
|
@model EventHub.Web.Pages.Organizations.Index |
||||
|
|
||||
|
<h1>Organizations</h1> |
||||
|
|
||||
|
<ul> |
||||
|
@foreach (var organization in Model.Organizations) |
||||
|
{ |
||||
|
<li>@organization.Name</li> |
||||
|
} |
||||
|
</ul> |
||||
@ -0,0 +1,26 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using EventHub.Organizations; |
||||
|
using Microsoft.AspNetCore.Mvc.RazorPages; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace EventHub.Web.Pages.Organizations |
||||
|
{ |
||||
|
public class Index : EventHubPageModel |
||||
|
{ |
||||
|
public IReadOnlyList<OrganizationInListDto> Organizations { get; set; } |
||||
|
|
||||
|
private readonly IOrganizationAppService _organizationAppService; |
||||
|
|
||||
|
public Index(IOrganizationAppService organizationAppService) |
||||
|
{ |
||||
|
_organizationAppService = organizationAppService; |
||||
|
} |
||||
|
|
||||
|
public async Task OnGetAsync() |
||||
|
{ |
||||
|
var result = await _organizationAppService.GetListAsync(new PagedResultRequestDto()); |
||||
|
Organizations = result.Items; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue