Browse Source

Make HttpApi.Host working

pull/1810/head
Halil İbrahim Kalkan 7 years ago
parent
commit
d040a364c6
  1. 7
      samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/BookManagementHttpApiHostModule.cs
  2. 2
      samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/EntityFrameworkCore/MyProjectHttpApiHostMigrationsDbContextFactory.cs
  3. 65
      samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/Migrations/20190914101054_Added_Books.Designer.cs
  4. 38
      samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/Migrations/20190914101054_Added_Books.cs
  5. 63
      samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/Migrations/MyProjectHttpApiHostMigrationsDbContextModelSnapshot.cs
  6. 13
      samples/BookStore-Modular/modules/book-management/test/Acme.BookStore.BookManagement.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs

7
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<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers
.Create(typeof(BookManagementApplicationModule).Assembly);
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)

2
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<MyProjectHttpApiHostMigrationsDbContext>()
.UseSqlServer(configuration.GetConnectionString("Default"));
.UseSqlServer(configuration.GetConnectionString("BookManagement"));
return new MyProjectHttpApiHostMigrationsDbContext(builder.Options);
}

65
samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/Migrations/20190914101054_Added_Books.Designer.cs

@ -0,0 +1,65 @@
// <auto-generated />
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<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties");
b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(128);
b.Property<float>("Price");
b.Property<DateTime>("PublishDate");
b.Property<int>("Type");
b.HasKey("Id");
b.ToTable("BmBooks");
});
#pragma warning restore 612, 618
}
}
}

38
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<Guid>(nullable: false),
ExtraProperties = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true),
CreationTime = table.Column<DateTime>(nullable: false),
CreatorId = table.Column<Guid>(nullable: true),
LastModificationTime = table.Column<DateTime>(nullable: true),
LastModifierId = table.Column<Guid>(nullable: true),
Name = table.Column<string>(maxLength: 128, nullable: false),
Type = table.Column<int>(nullable: false),
PublishDate = table.Column<DateTime>(nullable: false),
Price = table.Column<float>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BmBooks", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "BmBooks");
}
}
}

63
samples/BookStore-Modular/modules/book-management/host/Acme.BookStore.BookManagement.HttpApi.Host/Migrations/MyProjectHttpApiHostMigrationsDbContextModelSnapshot.cs

@ -0,0 +1,63 @@
// <auto-generated />
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<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.HasColumnName("ExtraProperties");
b.Property<DateTime?>("LastModificationTime")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnName("LastModifierId");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(128);
b.Property<float>("Price");
b.Property<DateTime>("PublishDate");
b.Property<int>("Type");
b.HasKey("Id");
b.ToTable("BmBooks");
});
#pragma warning restore 612, 618
}
}
}

13
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

Loading…
Cancel
Save