diff --git a/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/Controllers/ProductsController.cs b/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/Controllers/ProductsController.cs index eb57fe1..cfbf2d9 100644 --- a/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/Controllers/ProductsController.cs +++ b/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/Controllers/ProductsController.cs @@ -1,4 +1,7 @@ -using Microsoft.AspNetCore.Mvc; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using MultiTenancySample.DatabaseIsolationService.Entities; using MultiTenancySample.DatabaseIsolationService.EntityFrameworks; @@ -23,5 +26,14 @@ namespace MultiTenancySample.DatabaseIsolationService.Controllers return Ok(products); } + + [HttpPost] + public async Task CreateProduct(Product product) + { + await _dbContext.AddAsync(product); + await _dbContext.SaveChangesAsync(); + + return Ok(product); + } } } diff --git a/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/Entities/Product.cs b/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/Entities/Product.cs index e21a15b..4cca264 100644 --- a/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/Entities/Product.cs +++ b/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/Entities/Product.cs @@ -1,4 +1,7 @@ -namespace MultiTenancySample.DatabaseIsolationService.Entities +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace MultiTenancySample.DatabaseIsolationService.Entities { public class Product { diff --git a/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/EntityFrameworks/DataSeeding.cs b/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/EntityFrameworks/DataSeeding.cs index d4309f8..973b125 100644 --- a/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/EntityFrameworks/DataSeeding.cs +++ b/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/EntityFrameworks/DataSeeding.cs @@ -1,4 +1,7 @@ -using Microsoft.EntityFrameworkCore; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.EntityFrameworkCore; using MultiTenancySample.DatabaseIsolationService.Entities; using MultiTenancySample.ServiceDefaults; diff --git a/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/EntityFrameworks/DatabaseIsolationServiceDbContext.cs b/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/EntityFrameworks/DatabaseIsolationServiceDbContext.cs index cf32e91..364ddb5 100644 --- a/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/EntityFrameworks/DatabaseIsolationServiceDbContext.cs +++ b/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/EntityFrameworks/DatabaseIsolationServiceDbContext.cs @@ -1,4 +1,7 @@ -using Microsoft.EntityFrameworkCore; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.EntityFrameworkCore; using MultiTenancySample.DatabaseIsolationService.Entities; using MultiTenancySample.ServiceDefaults; diff --git a/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/Program.cs b/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/Program.cs index 43c67a6..4d5e8cf 100644 --- a/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/Program.cs +++ b/samples/MultiTenancySample/MultiTenancySample.DatabaseIsolationService/Program.cs @@ -1,3 +1,6 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using MultiTenancySample.DatabaseIsolationService.EntityFrameworks; using MultiTenancySample.ServiceDefaults; diff --git a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Controllers/ProductsController.cs b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Controllers/ProductsController.cs index 44a9d8a..d90318e 100644 --- a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Controllers/ProductsController.cs +++ b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Controllers/ProductsController.cs @@ -1,4 +1,7 @@ -using Microsoft.AspNetCore.Mvc; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using MultiTenancySample.FieldIsolationService.Entities; using MultiTenancySample.FieldIsolationService.EntityFrameworks; @@ -23,5 +26,15 @@ namespace MultiTenancySample.FieldIsolationService.Controllers return Ok(products); } + + [HttpPost] + public async Task CreateProduct(Product product) + { + await _dbContext.AddAsync(product); + + await _dbContext.SaveChangesAsync(); + + return Ok(product); + } } } diff --git a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Entities/IMultiTenant.cs b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Entities/IMultiTenant.cs index d08b099..d32de6d 100644 --- a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Entities/IMultiTenant.cs +++ b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Entities/IMultiTenant.cs @@ -1,4 +1,7 @@ -namespace MultiTenancySample.FieldIsolationService.Entities +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace MultiTenancySample.FieldIsolationService.Entities { public interface IMultiTenant { diff --git a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Entities/Product.cs b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Entities/Product.cs index 9ce4077..fe92bbf 100644 --- a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Entities/Product.cs +++ b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Entities/Product.cs @@ -1,4 +1,7 @@ -using System.Text.Json.Serialization; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using System.Text.Json.Serialization; namespace MultiTenancySample.FieldIsolationService.Entities { diff --git a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/DataSeeding.cs b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/DataSeeding.cs index 284097d..ee5ec20 100644 --- a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/DataSeeding.cs +++ b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/DataSeeding.cs @@ -1,16 +1,19 @@ -using Microsoft.EntityFrameworkCore; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.EntityFrameworkCore; using MultiTenancySample.FieldIsolationService.Entities; using MultiTenancySample.ServiceDefaults; namespace MultiTenancySample.FieldIsolationService.EntityFrameworks { - public class DataSeeding(IDbContextFactory dbContext, ICurrentTenant currentTenant) + public class DataSeeding(IDbContextFactory dbContextFactory, ICurrentTenant currentTenant) { public async Task SeedDataAsync() { currentTenant.SetTenant("Tenant1"); - FieldIsolationServiceDbContext dbContext1 = await dbContext.CreateDbContextAsync(); + FieldIsolationServiceDbContext dbContext1 = await dbContextFactory.CreateDbContextAsync(); if (await dbContext1.Database.EnsureCreatedAsync()) { @@ -25,7 +28,7 @@ namespace MultiTenancySample.FieldIsolationService.EntityFrameworks currentTenant.SetTenant("Tenant2"); - FieldIsolationServiceDbContext dbContext2 = await dbContext.CreateDbContextAsync(); + FieldIsolationServiceDbContext dbContext2 = await dbContextFactory.CreateDbContextAsync(); if (await dbContext2.Set().IgnoreQueryFilters().CountAsync() < 6) { diff --git a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/EntityTypeBuilderQueryFilterExtensions.cs b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/EntityTypeBuilderQueryFilterExtensions.cs index c96dbf0..7d431b1 100644 --- a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/EntityTypeBuilderQueryFilterExtensions.cs +++ b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/EntityTypeBuilderQueryFilterExtensions.cs @@ -1,4 +1,7 @@ -using Microsoft.EntityFrameworkCore.Metadata.Builders; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Query; using System.Linq.Expressions; diff --git a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/FieldIsolationServiceDbContext.cs b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/FieldIsolationServiceDbContext.cs index 46b209a..70ee0ff 100644 --- a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/FieldIsolationServiceDbContext.cs +++ b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/FieldIsolationServiceDbContext.cs @@ -1,4 +1,7 @@ -using Microsoft.EntityFrameworkCore; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; using MultiTenancySample.FieldIsolationService.Entities; using MultiTenancySample.ServiceDefaults; diff --git a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/TenantSaveChangesInterceptor.cs b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/TenantSaveChangesInterceptor.cs index 20435fb..495366f 100644 --- a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/TenantSaveChangesInterceptor.cs +++ b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/EntityFrameworks/TenantSaveChangesInterceptor.cs @@ -1,4 +1,7 @@ -using Microsoft.EntityFrameworkCore; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Diagnostics; using MultiTenancySample.FieldIsolationService.Entities; diff --git a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Program.cs b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Program.cs index 520be5e..19a01d2 100644 --- a/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Program.cs +++ b/samples/MultiTenancySample/MultiTenancySample.FieldIsolationService/Program.cs @@ -1,3 +1,6 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using Microsoft.EntityFrameworkCore; using MultiTenancySample.FieldIsolationService.EntityFrameworks; using MultiTenancySample.ServiceDefaults; diff --git a/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/Controllers/ProductsController.cs b/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/Controllers/ProductsController.cs index 2690a1b..c739b1c 100644 --- a/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/Controllers/ProductsController.cs +++ b/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/Controllers/ProductsController.cs @@ -1,4 +1,7 @@ -using Microsoft.AspNetCore.Mvc; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using MultiTenancySample.SchemaIsolationService.Entities; using MultiTenancySample.SchemaIsolationService.EntityFrameworks; diff --git a/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/Entities/Product.cs b/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/Entities/Product.cs index 27c2859..a1ccfd7 100644 --- a/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/Entities/Product.cs +++ b/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/Entities/Product.cs @@ -1,4 +1,7 @@ -namespace MultiTenancySample.SchemaIsolationService.Entities +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace MultiTenancySample.SchemaIsolationService.Entities { public class Product { diff --git a/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/EntityFrameworks/DataSeeding.cs b/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/EntityFrameworks/DataSeeding.cs index be8a4ec..9339c5a 100644 --- a/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/EntityFrameworks/DataSeeding.cs +++ b/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/EntityFrameworks/DataSeeding.cs @@ -1,4 +1,7 @@ -using Microsoft.EntityFrameworkCore; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.EntityFrameworkCore; using MultiTenancySample.SchemaIsolationService.Entities; using MultiTenancySample.ServiceDefaults; diff --git a/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/EntityFrameworks/SchemaIsolationDbContext.cs b/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/EntityFrameworks/SchemaIsolationDbContext.cs index 5a803a0..3d1586a 100644 --- a/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/EntityFrameworks/SchemaIsolationDbContext.cs +++ b/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/EntityFrameworks/SchemaIsolationDbContext.cs @@ -1,4 +1,7 @@ -using Microsoft.EntityFrameworkCore; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.EntityFrameworkCore; using MultiTenancySample.SchemaIsolationService.Entities; using MultiTenancySample.ServiceDefaults; diff --git a/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/Program.cs b/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/Program.cs index 5b1d09d..8753a7a 100644 --- a/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/Program.cs +++ b/samples/MultiTenancySample/MultiTenancySample.SchemaIsolationService/Program.cs @@ -1,3 +1,6 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using Microsoft.EntityFrameworkCore; using MultiTenancySample.SchemaIsolationService.EntityFrameworks; using MultiTenancySample.ServiceDefaults; diff --git a/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/CurrentTenant.cs b/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/CurrentTenant.cs index 108e6db..aed9971 100644 --- a/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/CurrentTenant.cs +++ b/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/CurrentTenant.cs @@ -1,4 +1,7 @@ -namespace MultiTenancySample.ServiceDefaults +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace MultiTenancySample.ServiceDefaults { public class CurrentTenant : ICurrentTenant { diff --git a/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/ICurrentTenant.cs b/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/ICurrentTenant.cs index 4cda38a..c8cf1d6 100644 --- a/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/ICurrentTenant.cs +++ b/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/ICurrentTenant.cs @@ -1,4 +1,7 @@ -namespace MultiTenancySample.ServiceDefaults +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace MultiTenancySample.ServiceDefaults { public interface ICurrentTenant { diff --git a/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/ITenantIdProvider.cs b/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/ITenantIdProvider.cs index 058b53e..663c2c4 100644 --- a/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/ITenantIdProvider.cs +++ b/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/ITenantIdProvider.cs @@ -1,4 +1,7 @@ -namespace MultiTenancySample.ServiceDefaults +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace MultiTenancySample.ServiceDefaults { public interface ITenantIdProvider { diff --git a/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/MultiTenancyExtensions.cs b/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/MultiTenancyExtensions.cs index 2a6f0d1..2304010 100644 --- a/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/MultiTenancyExtensions.cs +++ b/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/MultiTenancyExtensions.cs @@ -1,4 +1,7 @@ -using Microsoft.AspNetCore.Builder; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; namespace MultiTenancySample.ServiceDefaults diff --git a/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/TenantIdProvider.cs b/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/TenantIdProvider.cs index eda8382..5e30c73 100644 --- a/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/TenantIdProvider.cs +++ b/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/TenantIdProvider.cs @@ -1,4 +1,7 @@ -using Microsoft.AspNetCore.Http; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.AspNetCore.Http; namespace MultiTenancySample.ServiceDefaults { @@ -10,7 +13,7 @@ namespace MultiTenancySample.ServiceDefaults const string tenantKey = "tenant"; - if(httpContext.User.FindAll(tenantKey).Any()) + if (httpContext.User.FindAll(tenantKey).Any()) { return httpContext.User.FindFirst(tenantKey)?.Value; } diff --git a/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/TenantMiddleware.cs b/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/TenantMiddleware.cs index 1df756a..df864b1 100644 --- a/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/TenantMiddleware.cs +++ b/samples/MultiTenancySample/MultiTenancySample.ServiceDefaults/TenantMiddleware.cs @@ -1,4 +1,7 @@ -using Microsoft.AspNetCore.Http; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.AspNetCore.Http; namespace MultiTenancySample.ServiceDefaults {