Merge 723bd1209fd6ee5bf252c11a249af9400de4e5ea into 42abcad37ebbb133aa76570c46d34c4685376913
This commit is contained in:
commit
4e095f83ac
@ -304,10 +304,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
|||||||
var baseUri = _settings.PicBaseUrl;
|
var baseUri = _settings.PicBaseUrl;
|
||||||
var azureStorageEnabled = _settings.AzureStorageEnabled;
|
var azureStorageEnabled = _settings.AzureStorageEnabled;
|
||||||
|
|
||||||
foreach (var item in items)
|
items.ForEach(item => { item.FillProductUrl(baseUri, azureStorageEnabled: azureStorageEnabled); });
|
||||||
{
|
|
||||||
item.FillProductUrl(baseUri, azureStorageEnabled: azureStorageEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
@ -56,40 +56,18 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
|||||||
|
|
||||||
private string GetImageMimeTypeFromImageFileExtension(string extension)
|
private string GetImageMimeTypeFromImageFileExtension(string extension)
|
||||||
{
|
{
|
||||||
string mimetype;
|
string mimetype = extension switch
|
||||||
|
|
||||||
switch (extension)
|
|
||||||
{
|
{
|
||||||
case ".png":
|
".png" => "image/png",
|
||||||
mimetype = "image/png";
|
".gif" => "image/gif",
|
||||||
break;
|
".jpg" or ".jpeg" => "image/jpeg",
|
||||||
case ".gif":
|
".bmp" => "image/bmp",
|
||||||
mimetype = "image/gif";
|
".tiff" => "image/tiff",
|
||||||
break;
|
".wmf" => "image/wmf",
|
||||||
case ".jpg":
|
".jp2" => "image/jp2",
|
||||||
case ".jpeg":
|
".svg" => "image/svg+xml",
|
||||||
mimetype = "image/jpeg";
|
_ => "application/octet-stream",
|
||||||
break;
|
};
|
||||||
case ".bmp":
|
|
||||||
mimetype = "image/bmp";
|
|
||||||
break;
|
|
||||||
case ".tiff":
|
|
||||||
mimetype = "image/tiff";
|
|
||||||
break;
|
|
||||||
case ".wmf":
|
|
||||||
mimetype = "image/wmf";
|
|
||||||
break;
|
|
||||||
case ".jp2":
|
|
||||||
mimetype = "image/jp2";
|
|
||||||
break;
|
|
||||||
case ".svg":
|
|
||||||
mimetype = "image/svg+xml";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
mimetype = "application/octet-stream";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mimetype;
|
return mimetype;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,12 @@
|
|||||||
{
|
{
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
item.PictureUri = azureStorageEnabled
|
// https://www.linkedin.com/feed/update/urn:li:activity:6841055191211491328/
|
||||||
? picBaseUrl + item.PictureFileName
|
item.PictureUri = azureStorageEnabled switch
|
||||||
: picBaseUrl.Replace("[0]", item.Id.ToString());
|
{
|
||||||
|
true => picBaseUrl + item.PictureFileName,
|
||||||
|
_ => picBaseUrl.Replace("[0]", item.Id.ToString())
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Devspaces
|
|||||||
public class DevspacesRedirectUriValidator : IRedirectUriValidator
|
public class DevspacesRedirectUriValidator : IRedirectUriValidator
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
public DevspacesRedirectUriValidator(ILogger<DevspacesRedirectUriValidator> logger)
|
public DevspacesRedirectUriValidator(ILogger<DevspacesRedirectUriValidator> logger) => (_logger) = (logger);
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<bool> IsPostLogoutRedirectUriValidAsync(string requestedUri, Client client)
|
public Task<bool> IsPostLogoutRedirectUriValidAsync(string requestedUri, Client client)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,85 @@
|
|||||||
|
using IdentityServer4.Services;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.eShopOnContainers.Services.Identity.API;
|
||||||
|
using Microsoft.eShopOnContainers.Services.Identity.API.Certificates;
|
||||||
|
using Microsoft.eShopOnContainers.Services.Identity.API.Data;
|
||||||
|
using Microsoft.eShopOnContainers.Services.Identity.API.Devspaces;
|
||||||
|
using Microsoft.eShopOnContainers.Services.Identity.API.Models;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using Microsoft.eShopOnContainers.Services.Identity.API.Services;
|
||||||
|
|
||||||
|
namespace Identity.API.Extensions
|
||||||
|
{
|
||||||
|
public static class StartupConfigurationExtensions
|
||||||
|
{
|
||||||
|
public static void RegisterAppInsights(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
services.AddApplicationInsightsTelemetry(configuration);
|
||||||
|
services.AddApplicationInsightsKubernetesEnricher();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add framework services.
|
||||||
|
public static void ConfigureDatabase(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
services.AddDbContext<ApplicationDbContext>(options =>
|
||||||
|
options.UseSqlServer(configuration["ConnectionString"],
|
||||||
|
sqlServerOptionsAction: sqlOptions =>
|
||||||
|
{
|
||||||
|
sqlOptions.MigrationsAssembly(typeof(Startup).GetTypeInfo().Assembly.GetName().Name);
|
||||||
|
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
|
||||||
|
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
|
||||||
|
}));
|
||||||
|
|
||||||
|
services.AddIdentity<ApplicationUser, IdentityRole>()
|
||||||
|
.AddEntityFrameworkStores<ApplicationDbContext>()
|
||||||
|
.AddDefaultTokenProviders();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds IdentityServer
|
||||||
|
public static void ConfigureIdentityServer(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
var connectionString = configuration["ConnectionString"];
|
||||||
|
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
|
||||||
|
|
||||||
|
services.AddIdentityServer(x =>
|
||||||
|
{
|
||||||
|
x.IssuerUri = "null";
|
||||||
|
x.Authentication.CookieLifetime = TimeSpan.FromHours(2);
|
||||||
|
})
|
||||||
|
.AddDevspacesIfNeeded(configuration.GetValue("EnableDevspaces", false))
|
||||||
|
.AddSigningCredential(Certificate.Get())
|
||||||
|
.AddAspNetIdentity<ApplicationUser>()
|
||||||
|
.AddConfigurationStore(options =>
|
||||||
|
{
|
||||||
|
options.ConfigureDbContext = builder => builder.UseSqlServer(connectionString,
|
||||||
|
sqlServerOptionsAction: sqlOptions =>
|
||||||
|
{
|
||||||
|
sqlOptions.MigrationsAssembly(migrationsAssembly);
|
||||||
|
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
|
||||||
|
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.AddOperationalStore(options =>
|
||||||
|
{
|
||||||
|
options.ConfigureDbContext = builder => builder.UseSqlServer(connectionString,
|
||||||
|
sqlServerOptionsAction: sqlOptions =>
|
||||||
|
{
|
||||||
|
sqlOptions.MigrationsAssembly(migrationsAssembly);
|
||||||
|
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
|
||||||
|
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.Services.AddTransient<IProfileService, ProfileService>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ConfigureDependecyInjections(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddTransient<ILoginService<ApplicationUser>, EFLoginService>();
|
||||||
|
services.AddTransient<IRedirectService, RedirectService>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -63,8 +63,4 @@
|
|||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Extensions\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -21,6 +21,8 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Services
|
|||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//New Method ArgumentNullException.ThrowIfNull (obj) Added to .NET 6
|
||||||
|
//https://davidshergilashvili.space/2021/09/08/new-method-argumentnullexception-throwifnull-obj-added-to-net-6/
|
||||||
async public Task GetProfileDataAsync(ProfileDataRequestContext context)
|
async public Task GetProfileDataAsync(ProfileDataRequestContext context)
|
||||||
{
|
{
|
||||||
var subject = context.Subject ?? throw new ArgumentNullException(nameof(context.Subject));
|
var subject = context.Subject ?? throw new ArgumentNullException(nameof(context.Subject));
|
||||||
|
@ -1,18 +1,11 @@
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Extensions.DependencyInjection;
|
using Autofac.Extensions.DependencyInjection;
|
||||||
using HealthChecks.UI.Client;
|
using HealthChecks.UI.Client;
|
||||||
using IdentityServer4.Services;
|
using Identity.API.Extensions;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.DataProtection;
|
using Microsoft.AspNetCore.DataProtection;
|
||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.eShopOnContainers.Services.Identity.API.Certificates;
|
|
||||||
using Microsoft.eShopOnContainers.Services.Identity.API.Data;
|
|
||||||
using Microsoft.eShopOnContainers.Services.Identity.API.Devspaces;
|
|
||||||
using Microsoft.eShopOnContainers.Services.Identity.API.Models;
|
|
||||||
using Microsoft.eShopOnContainers.Services.Identity.API.Services;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||||
@ -20,37 +13,22 @@ using Microsoft.Extensions.Hosting;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using StackExchange.Redis;
|
using StackExchange.Redis;
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Identity.API
|
namespace Microsoft.eShopOnContainers.Services.Identity.API
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public Startup(IConfiguration configuration)
|
public Startup(IConfiguration configuration) => (Configuration) = (configuration);
|
||||||
{
|
|
||||||
Configuration = configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
public IConfiguration Configuration { get; }
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to add services to the container.
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
RegisterAppInsights(services);
|
services.RegisterAppInsights(Configuration);
|
||||||
|
|
||||||
// Add framework services.
|
// Add framework services.
|
||||||
services.AddDbContext<ApplicationDbContext>(options =>
|
services.ConfigureDatabase(Configuration);
|
||||||
options.UseSqlServer(Configuration["ConnectionString"],
|
|
||||||
sqlServerOptionsAction: sqlOptions =>
|
|
||||||
{
|
|
||||||
sqlOptions.MigrationsAssembly(typeof(Startup).GetTypeInfo().Assembly.GetName().Name);
|
|
||||||
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
|
|
||||||
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
|
|
||||||
}));
|
|
||||||
|
|
||||||
services.AddIdentity<ApplicationUser, IdentityRole>()
|
|
||||||
.AddEntityFrameworkStores<ApplicationDbContext>()
|
|
||||||
.AddDefaultTokenProviders();
|
|
||||||
|
|
||||||
services.Configure<AppSettings>(Configuration);
|
services.Configure<AppSettings>(Configuration);
|
||||||
|
|
||||||
@ -69,42 +47,10 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
|
|||||||
name: "IdentityDB-check",
|
name: "IdentityDB-check",
|
||||||
tags: new string[] { "IdentityDB" });
|
tags: new string[] { "IdentityDB" });
|
||||||
|
|
||||||
services.AddTransient<ILoginService<ApplicationUser>, EFLoginService>();
|
services.ConfigureDependecyInjections();
|
||||||
services.AddTransient<IRedirectService, RedirectService>();
|
|
||||||
|
|
||||||
var connectionString = Configuration["ConnectionString"];
|
|
||||||
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
|
|
||||||
|
|
||||||
// Adds IdentityServer
|
// Adds IdentityServer
|
||||||
services.AddIdentityServer(x =>
|
services.ConfigureIdentityServer(Configuration);
|
||||||
{
|
|
||||||
x.IssuerUri = "null";
|
|
||||||
x.Authentication.CookieLifetime = TimeSpan.FromHours(2);
|
|
||||||
})
|
|
||||||
.AddDevspacesIfNeeded(Configuration.GetValue("EnableDevspaces", false))
|
|
||||||
.AddSigningCredential(Certificate.Get())
|
|
||||||
.AddAspNetIdentity<ApplicationUser>()
|
|
||||||
.AddConfigurationStore(options =>
|
|
||||||
{
|
|
||||||
options.ConfigureDbContext = builder => builder.UseSqlServer(connectionString,
|
|
||||||
sqlServerOptionsAction: sqlOptions =>
|
|
||||||
{
|
|
||||||
sqlOptions.MigrationsAssembly(migrationsAssembly);
|
|
||||||
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
|
|
||||||
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.AddOperationalStore(options =>
|
|
||||||
{
|
|
||||||
options.ConfigureDbContext = builder => builder.UseSqlServer(connectionString,
|
|
||||||
sqlServerOptionsAction: sqlOptions =>
|
|
||||||
{
|
|
||||||
sqlOptions.MigrationsAssembly(migrationsAssembly);
|
|
||||||
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
|
|
||||||
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.Services.AddTransient<IProfileService, ProfileService>();
|
|
||||||
|
|
||||||
//services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
|
//services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
|
||||||
services.AddControllers();
|
services.AddControllers();
|
||||||
@ -174,11 +120,5 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RegisterAppInsights(IServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddApplicationInsightsTelemetry(Configuration);
|
|
||||||
services.AddApplicationInsightsKubernetesEnricher();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,6 +278,25 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* resource: https://twitter.com/CoderBora/status/1436392448356495362
|
||||||
|
* Swagger => Authorization: Bearer {token} : DO YOU WANT TO WRITE "Bearer" to the Value each time?
|
||||||
|
|
||||||
|
AddSecurityDefinition=>{ in Swagger
|
||||||
|
|
||||||
|
Type = SecuritySchemeType Choose "Http" instead of "ApiKey". Avoid typing "Bearer" instead of token
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
|
||||||
|
{
|
||||||
|
Description = @"JWT Authorization header using the Bearer scheme. Example: \'Authorization: Bearer {token}\'",
|
||||||
|
Name = "Authorization",
|
||||||
|
In = ParameterLocation.Header,
|
||||||
|
Type = SecuritySchemeType.Http,
|
||||||
|
Scheme = "Bearer"
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
options.OperationFilter<AuthorizeCheckOperationFilter>();
|
options.OperationFilter<AuthorizeCheckOperationFilter>();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
|
||||||
|
|
||||||
|
namespace Ordering.Infrastructure.EntityConfigurations
|
||||||
|
{
|
||||||
|
public class BaseConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : Entity
|
||||||
|
{
|
||||||
|
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
|
||||||
|
{
|
||||||
|
builder.Ignore(b => b.DomainEvents);
|
||||||
|
builder.HasKey(e => e.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,17 +5,12 @@ using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
|
|||||||
|
|
||||||
namespace Ordering.Infrastructure.EntityConfigurations
|
namespace Ordering.Infrastructure.EntityConfigurations
|
||||||
{
|
{
|
||||||
class BuyerEntityTypeConfiguration
|
class BuyerEntityTypeConfiguration : BaseConfiguration<Buyer>
|
||||||
: IEntityTypeConfiguration<Buyer>
|
|
||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<Buyer> buyerConfiguration)
|
public override void Configure(EntityTypeBuilder<Buyer> buyerConfiguration)
|
||||||
{
|
{
|
||||||
buyerConfiguration.ToTable("buyers", OrderingContext.DEFAULT_SCHEMA);
|
buyerConfiguration.ToTable("buyers", OrderingContext.DEFAULT_SCHEMA);
|
||||||
|
|
||||||
buyerConfiguration.HasKey(b => b.Id);
|
|
||||||
|
|
||||||
buyerConfiguration.Ignore(b => b.DomainEvents);
|
|
||||||
|
|
||||||
buyerConfiguration.Property(b => b.Id)
|
buyerConfiguration.Property(b => b.Id)
|
||||||
.UseHiLo("buyerseq", OrderingContext.DEFAULT_SCHEMA);
|
.UseHiLo("buyerseq", OrderingContext.DEFAULT_SCHEMA);
|
||||||
|
|
||||||
@ -36,6 +31,8 @@ namespace Ordering.Infrastructure.EntityConfigurations
|
|||||||
var navigation = buyerConfiguration.Metadata.FindNavigation(nameof(Buyer.PaymentMethods));
|
var navigation = buyerConfiguration.Metadata.FindNavigation(nameof(Buyer.PaymentMethods));
|
||||||
|
|
||||||
navigation.SetPropertyAccessMode(PropertyAccessMode.Field);
|
navigation.SetPropertyAccessMode(PropertyAccessMode.Field);
|
||||||
|
|
||||||
|
base.Configure(buyerConfiguration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,16 +7,12 @@ using System;
|
|||||||
|
|
||||||
namespace Ordering.Infrastructure.EntityConfigurations
|
namespace Ordering.Infrastructure.EntityConfigurations
|
||||||
{
|
{
|
||||||
class OrderEntityTypeConfiguration : IEntityTypeConfiguration<Order>
|
class OrderEntityTypeConfiguration : BaseConfiguration<Order>
|
||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<Order> orderConfiguration)
|
public override void Configure(EntityTypeBuilder<Order> orderConfiguration)
|
||||||
{
|
{
|
||||||
orderConfiguration.ToTable("orders", OrderingContext.DEFAULT_SCHEMA);
|
orderConfiguration.ToTable("orders", OrderingContext.DEFAULT_SCHEMA);
|
||||||
|
|
||||||
orderConfiguration.HasKey(o => o.Id);
|
|
||||||
|
|
||||||
orderConfiguration.Ignore(b => b.DomainEvents);
|
|
||||||
|
|
||||||
orderConfiguration.Property(o => o.Id)
|
orderConfiguration.Property(o => o.Id)
|
||||||
.UseHiLo("orderseq", OrderingContext.DEFAULT_SCHEMA);
|
.UseHiLo("orderseq", OrderingContext.DEFAULT_SCHEMA);
|
||||||
|
|
||||||
@ -81,6 +77,9 @@ namespace Ordering.Infrastructure.EntityConfigurations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
// .HasForeignKey("OrderStatusId");
|
// .HasForeignKey("OrderStatusId");
|
||||||
.HasForeignKey("_orderStatusId");
|
.HasForeignKey("_orderStatusId");
|
||||||
|
|
||||||
|
|
||||||
|
base.Configure(orderConfiguration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,17 +5,12 @@ using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
|
|||||||
|
|
||||||
namespace Ordering.Infrastructure.EntityConfigurations
|
namespace Ordering.Infrastructure.EntityConfigurations
|
||||||
{
|
{
|
||||||
class OrderItemEntityTypeConfiguration
|
class OrderItemEntityTypeConfiguration : BaseConfiguration<OrderItem>
|
||||||
: IEntityTypeConfiguration<OrderItem>
|
|
||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<OrderItem> orderItemConfiguration)
|
public override void Configure(EntityTypeBuilder<OrderItem> orderItemConfiguration)
|
||||||
{
|
{
|
||||||
orderItemConfiguration.ToTable("orderItems", OrderingContext.DEFAULT_SCHEMA);
|
orderItemConfiguration.ToTable("orderItems", OrderingContext.DEFAULT_SCHEMA);
|
||||||
|
|
||||||
orderItemConfiguration.HasKey(o => o.Id);
|
|
||||||
|
|
||||||
orderItemConfiguration.Ignore(b => b.DomainEvents);
|
|
||||||
|
|
||||||
orderItemConfiguration.Property(o => o.Id)
|
orderItemConfiguration.Property(o => o.Id)
|
||||||
.UseHiLo("orderitemseq");
|
.UseHiLo("orderitemseq");
|
||||||
|
|
||||||
@ -54,6 +49,8 @@ namespace Ordering.Infrastructure.EntityConfigurations
|
|||||||
.UsePropertyAccessMode(PropertyAccessMode.Field)
|
.UsePropertyAccessMode(PropertyAccessMode.Field)
|
||||||
.HasColumnName("PictureUrl")
|
.HasColumnName("PictureUrl")
|
||||||
.IsRequired(false);
|
.IsRequired(false);
|
||||||
|
|
||||||
|
base.Configure(orderItemConfiguration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,17 +6,12 @@ using System;
|
|||||||
|
|
||||||
namespace Ordering.Infrastructure.EntityConfigurations
|
namespace Ordering.Infrastructure.EntityConfigurations
|
||||||
{
|
{
|
||||||
class PaymentMethodEntityTypeConfiguration
|
class PaymentMethodEntityTypeConfiguration : BaseConfiguration<PaymentMethod>
|
||||||
: IEntityTypeConfiguration<PaymentMethod>
|
|
||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<PaymentMethod> paymentConfiguration)
|
public override void Configure(EntityTypeBuilder<PaymentMethod> paymentConfiguration)
|
||||||
{
|
{
|
||||||
paymentConfiguration.ToTable("paymentmethods", OrderingContext.DEFAULT_SCHEMA);
|
paymentConfiguration.ToTable("paymentmethods", OrderingContext.DEFAULT_SCHEMA);
|
||||||
|
|
||||||
paymentConfiguration.HasKey(b => b.Id);
|
|
||||||
|
|
||||||
paymentConfiguration.Ignore(b => b.DomainEvents);
|
|
||||||
|
|
||||||
paymentConfiguration.Property(b => b.Id)
|
paymentConfiguration.Property(b => b.Id)
|
||||||
.UseHiLo("paymentseq", OrderingContext.DEFAULT_SCHEMA);
|
.UseHiLo("paymentseq", OrderingContext.DEFAULT_SCHEMA);
|
||||||
|
|
||||||
@ -60,6 +55,8 @@ namespace Ordering.Infrastructure.EntityConfigurations
|
|||||||
paymentConfiguration.HasOne(p => p.CardType)
|
paymentConfiguration.HasOne(p => p.CardType)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("_cardTypeId");
|
.HasForeignKey("_cardTypeId");
|
||||||
|
|
||||||
|
base.Configure(paymentConfiguration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user