Browse Source

Created first organizations page.

pull/15/head
Halil İbrahim Kalkan 6 years ago
parent
commit
124a0643c4
  1. 11
      eventhub/src/EventHub.Application.Contracts/Organizations/IOrganizationAppService.cs
  2. 12
      eventhub/src/EventHub.Application.Contracts/Organizations/OrganizationInListDto.cs
  3. 5
      eventhub/src/EventHub.Application/EventHubAppService.cs
  4. 5
      eventhub/src/EventHub.Application/EventHubApplicationAutoMapperProfile.cs
  5. 33
      eventhub/src/EventHub.Application/Organizations/OrganizationAppService.cs
  6. 3
      eventhub/src/EventHub.Domain.Shared/Organizations/OrganizationContst.cs
  7. 9
      eventhub/src/EventHub.Domain/Organizations/Organization.cs
  8. 2244
      eventhub/src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210116193331_Added_Organizations.Designer.cs
  9. 50
      eventhub/src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210116193331_Added_Organizations.cs
  10. 59
      eventhub/src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/EventHubMigrationsDbContextModelSnapshot.cs
  11. 9
      eventhub/src/EventHub.EntityFrameworkCore/EntityFrameworkCore/EventHubDbContext.cs
  12. 24
      eventhub/src/EventHub.EntityFrameworkCore/EntityFrameworkCore/EventHubDbContextModelCreatingExtensions.cs
  13. 11
      eventhub/src/EventHub.Web/Pages/Organizations/Index.cshtml
  14. 26
      eventhub/src/EventHub.Web/Pages/Organizations/Index.cshtml.cs

11
eventhub/src/EventHub.Application.Contracts/Organizations/IOrganizationAppService.cs

@ -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);
}
}

12
eventhub/src/EventHub.Application.Contracts/Organizations/OrganizationInListDto.cs

@ -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; }
}
}

5
eventhub/src/EventHub.Application/EventHubAppService.cs

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using EventHub.Localization;
using EventHub.Localization;
using Volo.Abp.Application.Services;
namespace EventHub

5
eventhub/src/EventHub.Application/EventHubApplicationAutoMapperProfile.cs

@ -1,4 +1,5 @@
using AutoMapper;
using EventHub.Organizations;
namespace EventHub
{
@ -6,9 +7,7 @@ namespace EventHub
{
public EventHubApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<Organization, OrganizationInListDto>();
}
}
}

33
eventhub/src/EventHub.Application/Organizations/OrganizationAppService.cs

@ -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)
);
}
}
}

3
eventhub/src/EventHub.Domain.Shared/Organizations/OrganizationContst.cs

@ -4,5 +4,8 @@
{
public const int MinNameLength = 2;
public const int MaxNameLength = 32;
public const int MinDisplayNameLength = 2;
public const int MaxDisplayNameLength = 128;
}
}

9
eventhub/src/EventHub.Domain/Organizations/Organization.cs

@ -6,6 +6,8 @@ namespace EventHub.Organizations
{
public class Organization : AggregateRoot<Guid>
{
public Guid OwnerUserId { get; set; }
public string Name { get; private set; }
public string DisplayName { get; set; }
@ -26,15 +28,16 @@ namespace EventHub.Organizations
private Organization()
{
}
public Organization(
internal Organization(
Guid id,
Guid ownerUserId,
string name,
string displayName)
: base(id)
{
OwnerUserId = ownerUserId;
SetName(name);
SetDisplayName(displayName);
}
@ -46,7 +49,7 @@ namespace EventHub.Organizations
public void SetDisplayName(string displayName)
{
DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName));
DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName), OrganizationConsts.MaxDisplayNameLength, OrganizationConsts.MinDisplayNameLength);
}
}
}

2244
eventhub/src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210116193331_Added_Organizations.Designer.cs

File diff suppressed because it is too large

50
eventhub/src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/20210116193331_Added_Organizations.cs

@ -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");
}
}
}

59
eventhub/src/EventHub.EntityFrameworkCore.DbMigrations/Migrations/EventHubMigrationsDbContextModelSnapshot.cs

@ -21,6 +21,65 @@ namespace EventHub.Migrations
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.2");
modelBuilder.Entity("EventHub.Organizations.Organization", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("DisplayName")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<string>("FacebookUsername")
.HasColumnType("nvarchar(max)");
b.Property<string>("GitHubUsername")
.HasColumnType("nvarchar(max)");
b.Property<string>("InstagramUsername")
.HasColumnType("nvarchar(max)");
b.Property<string>("MediumUsername")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property<Guid>("OwnerUserId")
.HasColumnType("uniqueidentifier");
b.Property<string>("TwitterUsername")
.HasColumnType("nvarchar(max)");
b.Property<string>("Website")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("DisplayName");
b.HasIndex("Name");
b.ToTable("AppOrganizations");
});
modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b =>
{
b.Property<Guid>("Id")

9
eventhub/src/EventHub.EntityFrameworkCore/EntityFrameworkCore/EventHubDbContext.cs

@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using EventHub.Organizations;
using Microsoft.EntityFrameworkCore;
using EventHub.Users;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
@ -22,9 +23,7 @@ namespace EventHub.EntityFrameworkCore
{
public DbSet<AppUser> Users { get; set; }
/* Add DbSet properties for your Aggregate Roots / Entities here.
* Also map them inside EventHubDbContextModelCreatingExtensions.ConfigureEventHub
*/
public DbSet<Organization> Organizations { get; set; }
public EventHubDbContext(DbContextOptions<EventHubDbContext> options)
: base(options)
@ -41,7 +40,7 @@ namespace EventHub.EntityFrameworkCore
builder.Entity<AppUser>(b =>
{
b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "Users"); //Sharing the same table "AbpUsers" with the IdentityUser
b.ConfigureByConvention();
b.ConfigureAbpUser();

24
eventhub/src/EventHub.EntityFrameworkCore/EntityFrameworkCore/EventHubDbContextModelCreatingExtensions.cs

@ -1,5 +1,7 @@
using Microsoft.EntityFrameworkCore;
using EventHub.Organizations;
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling;
namespace EventHub.EntityFrameworkCore
{
@ -11,12 +13,18 @@ namespace EventHub.EntityFrameworkCore
/* Configure your own tables/entities inside here */
//builder.Entity<YourEntity>(b =>
//{
// b.ToTable(EventHubConsts.DbTablePrefix + "YourEntities", EventHubConsts.DbSchema);
// b.ConfigureByConvention(); //auto configure for the base class props
// //...
//});
builder.Entity<Organization>(b =>
{
b.ToTable(EventHubConsts.DbTablePrefix + "Organizations", EventHubConsts.DbSchema);
b.ConfigureByConvention();
b.Property(x => x.Name).IsRequired().HasMaxLength(OrganizationConsts.MaxNameLength);
b.Property(x => x.DisplayName).IsRequired().HasMaxLength(OrganizationConsts.MaxDisplayNameLength);
b.HasIndex(x => x.Name);
b.HasIndex(x => x.DisplayName);
});
}
}
}
}

11
eventhub/src/EventHub.Web/Pages/Organizations/Index.cshtml

@ -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>

26
eventhub/src/EventHub.Web/Pages/Organizations/Index.cshtml.cs

@ -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…
Cancel
Save