Skip to content

Commit

Permalink
another shot #12
Browse files Browse the repository at this point in the history
  • Loading branch information
thangchung committed Jun 12, 2021
1 parent 44e9fd2 commit 7adcff2
Show file tree
Hide file tree
Showing 69 changed files with 489 additions and 395 deletions.
Binary file added assets/package_dependencies.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>preview</LangVersion>
<RootNamespace>CustomerService.Application</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddCore(builder.Configuration, typeof(Anchor))
.AddPostgresDbContext<MainDbContext, CustomerService.Infrastructure.Anchor>(
.AddPostgresDbContext<MainDbContext>(
builder.Configuration.GetConnectionString("postgres"),
svc => svc.AddRepository(typeof(Repository<>)))
.AddRestClient(typeof(ICountryApi), AppConsts.SettingAppName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ namespace CustomerService.Application.V1
{
[ApiVersionNeutral]
[ApiExplorerSettings(IgnoreApi = true)]
public class TransactionalOutboxProcesssor : BaseController
public class TransactionalOutboxProcessor : BaseController
{
private readonly ITransactionalOutboxProcessor _outboxProcessor;

public TransactionalOutboxProcesssor(ITransactionalOutboxProcessor outboxProcessor)
public TransactionalOutboxProcessor(ITransactionalOutboxProcessor outboxProcessor)
{
_outboxProcessor = outboxProcessor ?? throw new ArgumentNullException(nameof(outboxProcessor));
}
Expand Down
4 changes: 4 additions & 0 deletions samples/Customer/CustomerService.AppCore/Anchor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace CustomerService.Application.V1
{
public struct Anchor { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<RootNamespace>CustomerService.Core</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand Down
31 changes: 0 additions & 31 deletions samples/Customer/CustomerService.Application/Dockerfile

This file was deleted.

71 changes: 71 additions & 0 deletions samples/Customer/CustomerService.Infrastructure/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using N8T.Infrastructure;
using N8T.Infrastructure.Bus;
using N8T.Infrastructure.EfCore;
using N8T.Infrastructure.Swagger;
using N8T.Infrastructure.TransactionalOutbox;
using N8T.Infrastructure.Validator;
using ProductService.Infrastructure.Data;
using AppCoreAnchor = ProductService.AppCore.Anchor;

namespace ProductService.Infrastructure
{
public static class Extensions
{
private const string CorsName = "api";
private const string DbName = "postgres";

public static IServiceCollection AddCoreServices(this IServiceCollection services,
IConfiguration config, IWebHostEnvironment env, Type apiType)
{
services.AddCors(options =>
{
options.AddPolicy(CorsName, policy =>
{
policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
});
});

services.AddHttpContextAccessor();
services.AddCustomMediatR(new[] {typeof(AppCoreAnchor)});
services.AddCustomValidators(new[] {typeof(AppCoreAnchor)});
services.AddDaprClient();
services.AddControllers().AddMessageBroker(config);
services.AddTransactionalOutbox(config);
services.AddSwagger(apiType);

services.AddPostgresDbContext<MainDbContext>(
config.GetConnectionString(DbName),
svc => svc.AddRepository(typeof(Repository<>)));

return services;
}

public static IApplicationBuilder UseCoreApplication(this WebApplication app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseCors(CorsName);
app.UseRouting();
app.UseCloudEvents();

app.UseEndpoints(endpoints =>
{
endpoints.MapSubscribeHandler();
endpoints.MapDefaultControllerRoute();
});

var provider = app.Services.GetService<IApiVersionDescriptionProvider>();
return app.UseSwagger(provider);
}
}
}
12 changes: 12 additions & 0 deletions samples/DataContracts/CoolStore.AppContracts/Dtos/CountryDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace CoolStore.AppContracts.Dtos
{
public class CountryDto
{
public string Name { get; set; }
public Guid Id { get; set; }
public DateTime Created { get; set; }
public DateTime? Updated { get; set; }
}
}

This file was deleted.

15 changes: 15 additions & 0 deletions samples/DataContracts/CoolStore.AppContracts/Dtos/CreditCardDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace CoolStore.AppContracts.Dtos
{
public class CreditCardDto
{
public string NameOnCard { get; set; }
public string CardNumber { get; set; }
public bool Active { get; set; }
public DateTime Expiry { get; set; }
public Guid Id { get; set; }
public DateTime Created { get; set; }
public DateTime? Updated { get; set; }
}
}
16 changes: 16 additions & 0 deletions samples/DataContracts/CoolStore.AppContracts/Dtos/CustomerDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace CoolStore.AppContracts.Dtos
{
public class CustomerDto
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public decimal Balance { get; set; }
public Guid CountryId { get; set; }
public Guid Id { get; set; }
public DateTime Created { get; set; }
public DateTime? Updated { get; set; }
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace CoolStore.AppContracts.Dtos
{
public class ProductCodeDto
{
public string Name { get; set; }
public Guid Id { get; set; }
public DateTime Created { get; set; }
public DateTime? Updated { get; set; }
}
}
19 changes: 19 additions & 0 deletions samples/DataContracts/CoolStore.AppContracts/Dtos/ProductDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;

namespace CoolStore.AppContracts.Dtos
{
public class ProductDto
{
public string Name { get; set; }
public bool Active { get; set; }
public int Quantity { get; set; }
public decimal Cost { get; set; }
public Guid ProductCodeId { get; set; }
public ProductCodeDto Code { get; set; }
public IEnumerable<ReturnDto> Returns { get; set; }
public Guid Id { get; set; }
public DateTime Created { get; set; }
public DateTime? Updated { get; set; }
}
}

0 comments on commit 7adcff2

Please sign in to comment.