Added Acme.BookStore.ConsoleApiClient project

pull/691/head
Halil ibrahim Kalkan 6 years ago
parent 197a11cfb4
commit 1c71c9cc9b

@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Acme.BookStore.Application.
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Acme.BookStore.Web.Tests", "test\Acme.BookStore.Web.Tests\Acme.BookStore.Web.Tests.csproj", "{5F1B28C6-8D0C-4155-92D0-252F7EA5F674}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Acme.BookStore.Web.Tests", "test\Acme.BookStore.Web.Tests\Acme.BookStore.Web.Tests.csproj", "{5F1B28C6-8D0C-4155-92D0-252F7EA5F674}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Acme.BookStore.ConsoleApiClient", "test\Acme.BookStore.ConsoleApiClient\Acme.BookStore.ConsoleApiClient.csproj", "{3DED9AA7-1FC4-435D-9934-BCD37B43F744}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -49,6 +51,10 @@ Global
{5F1B28C6-8D0C-4155-92D0-252F7EA5F674}.Debug|Any CPU.Build.0 = Debug|Any CPU {5F1B28C6-8D0C-4155-92D0-252F7EA5F674}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F1B28C6-8D0C-4155-92D0-252F7EA5F674}.Release|Any CPU.ActiveCfg = Release|Any CPU {5F1B28C6-8D0C-4155-92D0-252F7EA5F674}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F1B28C6-8D0C-4155-92D0-252F7EA5F674}.Release|Any CPU.Build.0 = Release|Any CPU {5F1B28C6-8D0C-4155-92D0-252F7EA5F674}.Release|Any CPU.Build.0 = Release|Any CPU
{3DED9AA7-1FC4-435D-9934-BCD37B43F744}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3DED9AA7-1FC4-435D-9934-BCD37B43F744}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DED9AA7-1FC4-435D-9934-BCD37B43F744}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3DED9AA7-1FC4-435D-9934-BCD37B43F744}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -60,6 +66,7 @@ Global
{068855E8-9240-4F1A-910B-CF825794513B} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} {068855E8-9240-4F1A-910B-CF825794513B} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{50B2631D-129C-47B3-A587-029CCD6099BC} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {50B2631D-129C-47B3-A587-029CCD6099BC} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
{5F1B28C6-8D0C-4155-92D0-252F7EA5F674} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {5F1B28C6-8D0C-4155-92D0-252F7EA5F674} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
{3DED9AA7-1FC4-435D-9934-BCD37B43F744} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F} SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F}

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Autofac" Version="0.8.0" />
<PackageReference Include="Volo.Abp.Http.Client" Version="0.8.0" />
<ProjectReference Include="..\..\src\Acme.BookStore.Application\Acme.BookStore.Application.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,26 @@
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.DependencyInjection;
namespace Acme.BookStore.ConsoleApiClient
{
public class ApiClientDemoService : ITransientDependency
{
private readonly IBookAppService _bookAppService;
public ApiClientDemoService(IBookAppService bookAppService)
{
_bookAppService = bookAppService;
}
public async Task RunAsync()
{
var output = await _bookAppService.GetListAsync(new PagedAndSortedResultRequestDto());
foreach (var bookDto in output.Items)
{
Console.WriteLine($"[BOOK {bookDto.Id}] Name={bookDto.Name}, Price={bookDto.Price}");
}
}
}
}

@ -0,0 +1,27 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Autofac;
using Volo.Abp.Http.Client;
using Volo.Abp.Modularity;
namespace Acme.BookStore.ConsoleApiClient
{
[DependsOn(
typeof(AbpAutofacModule),
typeof(AbpHttpClientModule),
typeof(BookStoreApplicationModule)
)]
public class ConsoleApiClientModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.Configure<RemoteServiceOptions>(options =>
{
options.RemoteServices.Default = new RemoteServiceConfiguration("http://localhost:53929/");
});
context.Services.AddHttpClientProxies(
typeof(BookStoreApplicationModule).Assembly
);
}
}
}

@ -0,0 +1,30 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.Threading;
namespace Acme.BookStore.ConsoleApiClient
{
class Program
{
static void Main(string[] args)
{
using (var application = AbpApplicationFactory.Create<ConsoleApiClientModule>(options =>
{
options.UseAutofac();
}))
{
application.Initialize();
using (var scope = application.ServiceProvider.CreateScope())
{
var demoService = scope.ServiceProvider.GetRequiredService<ApiClientDemoService>();
AsyncHelper.RunSync(() => demoService.RunAsync());
}
Console.WriteLine("Press ENTER to stop application...");
Console.ReadLine();
}
}
}
}
Loading…
Cancel
Save