diff --git a/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/BookManagementHttpApiHostModule.cs b/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/BookManagementHttpApiHostModule.cs index 87169b4e36..30fab46ad6 100644 --- a/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/BookManagementHttpApiHostModule.cs +++ b/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/BookManagementHttpApiHostModule.cs @@ -9,6 +9,7 @@ using StackExchange.Redis; using Swashbuckle.AspNetCore.Swagger; using Volo.Abp; using Volo.Abp.AspNetCore.MultiTenancy; +using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AuditLogging.EntityFrameworkCore; using Volo.Abp.Autofac; using Volo.Abp.EntityFrameworkCore; @@ -98,6 +99,12 @@ namespace Acme.BookStore.BookManagement .AddDataProtection() .PersistKeysToStackExchangeRedis(redis, "BookManagement-Protection-Keys"); } + + Configure(options => + { + options.ConventionalControllers + .Create(typeof(BookManagementApplicationModule).Assembly); + }); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/EntityFrameworkCore/MyProjectHttpApiHostMigrationsDbContextFactory.cs b/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/EntityFrameworkCore/MyProjectHttpApiHostMigrationsDbContextFactory.cs index 954dd46a4f..90798873d4 100644 --- a/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/EntityFrameworkCore/MyProjectHttpApiHostMigrationsDbContextFactory.cs +++ b/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/EntityFrameworkCore/MyProjectHttpApiHostMigrationsDbContextFactory.cs @@ -12,7 +12,7 @@ namespace Acme.BookStore.BookManagement.EntityFrameworkCore var configuration = BuildConfiguration(); var builder = new DbContextOptionsBuilder() - .UseSqlServer(configuration.GetConnectionString("Default")); + .UseSqlServer(configuration.GetConnectionString("BookManagement")); return new MyProjectHttpApiHostMigrationsDbContext(builder.Options); } diff --git a/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/Migrations/20190914101054_Added_Books.Designer.cs b/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/Migrations/20190914101054_Added_Books.Designer.cs new file mode 100644 index 0000000000..2dbb894c2b --- /dev/null +++ b/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/Migrations/20190914101054_Added_Books.Designer.cs @@ -0,0 +1,65 @@ +// +using System; +using Acme.BookStore.BookManagement.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace Acme.BookStore.BookManagement.Migrations +{ + [DbContext(typeof(MyProjectHttpApiHostMigrationsDbContext))] + [Migration("20190914101054_Added_Books")] + partial class Added_Books + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.6-servicing-10079") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Acme.BookStore.BookManagement.Books.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128); + + b.Property("Price"); + + b.Property("PublishDate"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.ToTable("BmBooks"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/Migrations/20190914101054_Added_Books.cs b/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/Migrations/20190914101054_Added_Books.cs new file mode 100644 index 0000000000..628a63b54c --- /dev/null +++ b/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/Migrations/20190914101054_Added_Books.cs @@ -0,0 +1,38 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Acme.BookStore.BookManagement.Migrations +{ + public partial class Added_Books : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "BmBooks", + columns: table => new + { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(nullable: true), + CreationTime = table.Column(nullable: false), + CreatorId = table.Column(nullable: true), + LastModificationTime = table.Column(nullable: true), + LastModifierId = table.Column(nullable: true), + Name = table.Column(maxLength: 128, nullable: false), + Type = table.Column(nullable: false), + PublishDate = table.Column(nullable: false), + Price = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BmBooks", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "BmBooks"); + } + } +} diff --git a/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/Migrations/MyProjectHttpApiHostMigrationsDbContextModelSnapshot.cs b/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/Migrations/MyProjectHttpApiHostMigrationsDbContextModelSnapshot.cs new file mode 100644 index 0000000000..b8bb722136 --- /dev/null +++ b/samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/Migrations/MyProjectHttpApiHostMigrationsDbContextModelSnapshot.cs @@ -0,0 +1,63 @@ +// +using System; +using Acme.BookStore.BookManagement.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace Acme.BookStore.BookManagement.Migrations +{ + [DbContext(typeof(MyProjectHttpApiHostMigrationsDbContext))] + partial class MyProjectHttpApiHostMigrationsDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.6-servicing-10079") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Acme.BookStore.BookManagement.Books.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnName("ConcurrencyStamp"); + + b.Property("CreationTime") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnName("CreatorId"); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("LastModificationTime") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnName("LastModifierId"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128); + + b.Property("Price"); + + b.Property("PublishDate"); + + b.Property("Type"); + + b.HasKey("Id"); + + b.ToTable("BmBooks"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/samples/BookStore-Modular/modules/book-management/test/Acme.BookStore.BookManagement.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs b/samples/BookStore-Modular/modules/book-management/test/Acme.BookStore.BookManagement.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs index 2698f976f0..392159cb4c 100644 --- a/samples/BookStore-Modular/modules/book-management/test/Acme.BookStore.BookManagement.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs +++ b/samples/BookStore-Modular/modules/book-management/test/Acme.BookStore.BookManagement.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs @@ -1,8 +1,10 @@ using System; using System.Net.Http; using System.Threading.Tasks; +using Acme.BookStore.BookManagement.Books; using IdentityModel.Client; using Acme.BookStore.BookManagement.Samples; +using Volo.Abp.Application.Dtos; using Volo.Abp.Configuration; using Volo.Abp.DependencyInjection; using Volo.Abp.IdentityModel; @@ -14,15 +16,18 @@ namespace Acme.BookStore.BookManagement private readonly ISampleAppService _sampleAppService; private readonly IIdentityModelAuthenticationService _authenticationService; private readonly IConfigurationAccessor _configurationAccessor; + private readonly IBookAppService _bookAppService; public ClientDemoService( ISampleAppService sampleAppService, IIdentityModelAuthenticationService authenticationService, - IConfigurationAccessor configurationAccessor) + IConfigurationAccessor configurationAccessor, + IBookAppService bookAppService) { _sampleAppService = sampleAppService; _authenticationService = authenticationService; _configurationAccessor = configurationAccessor; + _bookAppService = bookAppService; } public async Task RunAsync() @@ -30,6 +35,12 @@ namespace Acme.BookStore.BookManagement await TestWithDynamicProxiesAsync(); await TestWithHttpClientAndIdentityModelAuthenticationServiceAsync(); await TestAllManuallyAsync(); + + var result = await _bookAppService.GetListAsync(new PagedAndSortedResultRequestDto()); + foreach (var bookDto in result.Items) + { + Console.WriteLine(bookDto.Name); + } } /* Shows how to perform an HTTP request to the API using ABP's dynamic c# proxy