Browse Source

Merge pull request #1 from Espent1004/tenantManager

Adding tenantManger project
pull/1240/head
Espent1004 5 years ago
committed by GitHub
parent
commit
af3167ee83
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 976 additions and 3 deletions
  1. +8
    -0
      docker-compose.override.yml
  2. +8
    -0
      docker-compose.yml
  3. +111
    -3
      eShopOnContainers-ServicesAndWebApps.sln
  4. +106
    -0
      src/Services/TenantManager/TenantManager/Controllers/CustomisationsController.cs
  5. +106
    -0
      src/Services/TenantManager/TenantManager/Controllers/MethodsController.cs
  6. +105
    -0
      src/Services/TenantManager/TenantManager/Controllers/TenantsController.cs
  7. +45
    -0
      src/Services/TenantManager/TenantManager/Controllers/ValuesController.cs
  8. +35
    -0
      src/Services/TenantManager/TenantManager/Data/TenantManagerContext.cs
  9. +70
    -0
      src/Services/TenantManager/TenantManager/Database/DbInitializer.cs
  10. +59
    -0
      src/Services/TenantManager/TenantManager/Dockerfile
  11. +16
    -0
      src/Services/TenantManager/TenantManager/Models/Customisation.cs
  12. +15
    -0
      src/Services/TenantManager/TenantManager/Models/Methods.cs
  13. +16
    -0
      src/Services/TenantManager/TenantManager/Models/Tenant.cs
  14. +44
    -0
      src/Services/TenantManager/TenantManager/Program.cs
  15. +42
    -0
      src/Services/TenantManager/TenantManager/Properties/launchSettings.json
  16. +134
    -0
      src/Services/TenantManager/TenantManager/Startup.cs
  17. +25
    -0
      src/Services/TenantManager/TenantManager/TenantManager.csproj
  18. +13
    -0
      src/Services/TenantManager/TenantManager/TenantManagerSettings.cs
  19. +9
    -0
      src/Services/TenantManager/TenantManager/appsettings.Development.json
  20. +9
    -0
      src/Services/TenantManager/TenantManager/appsettings.json

+ 8
- 0
docker-compose.override.yml View File

@ -49,12 +49,20 @@ services:
- WebShoppingAggClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5121
- WebhooksApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5113
- WebhooksWebClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5114
- TenantManagerApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5115
- UseCustomizationData=True
- ApplicationInsights__InstrumentationKey=${INSTRUMENTATION_KEY}
- OrchestratorType=${ORCHESTRATOR_TYPE}
ports:
- "5105:80"
tenantmanager:
environment:
- ConnectionString=${ESHOP_AZURE_CATALOG_DB:-Server=sql.data;Database=Microsoft.eShopOnContainers.Services.TenantManagerDb;User Id=sa;Password=Pass@word}
ports:
- "5115:80"
basket.api:
environment:
- ASPNETCORE_ENVIRONMENT=Development


+ 8
- 0
docker-compose.yml View File

@ -35,6 +35,14 @@ services:
- identity.api
- rabbitmq
tenantmanager:
image: ${REGISTRY:-eshop}/tenantmanager:${PLATFORM:-linux}-${TAG:-latest}
build:
context: .
dockerfile: src/Services/TenantManager/TenantManager/Dockerfile
depends_on:
- sql.data
catalog.api:
image: ${REGISTRY:-eshop}/catalog.api:${PLATFORM:-linux}-${TAG:-latest}
build:


+ 111
- 3
eShopOnContainers-ServicesAndWebApps.sln View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
# Visual Studio Version 16
VisualStudioVersion = 16.0.29306.81
MinimumVisualStudioVersion = 10.0.40219.1
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{FEA0C318-FFED-4D39-8781-265718CA43DD}"
EndProject
@ -148,7 +148,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebhookClient", "src\Web\We
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Devspace.Support", "Devspace.Support", "{68F5041D-51F2-4630-94B6-B49789F5E51A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Devspaces.Support", "src\BuildingBlocks\Devspaces.Support\Devspaces.Support.csproj", "{56C2EF0B-6BF2-41D9-BE07-6E6D08D06B35}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Devspaces.Support", "src\BuildingBlocks\Devspaces.Support\Devspaces.Support.csproj", "{56C2EF0B-6BF2-41D9-BE07-6E6D08D06B35}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TenantCustomisations", "TenantCustomisations", "{D2D53ADC-5230-4EF4-95B0-31FD734992F6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TenantACustomisations", "..\TenantACustomisations\TenantACustomisations.csproj", "{6CBF0D7F-7566-428E-B704-4059A10FFD52}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TenantManager", "TenantManager", "{71587505-2945-4286-BF0B-BA4C004B0BA7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TenantManager", "src\Services\TenantManager\TenantManager\TenantManager.csproj", "{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -1796,6 +1804,102 @@ Global
{56C2EF0B-6BF2-41D9-BE07-6E6D08D06B35}.Release|x64.Build.0 = Release|Any CPU
{56C2EF0B-6BF2-41D9-BE07-6E6D08D06B35}.Release|x86.ActiveCfg = Release|Any CPU
{56C2EF0B-6BF2-41D9-BE07-6E6D08D06B35}.Release|x86.Build.0 = Release|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.AppStore|ARM.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.AppStore|iPhone.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.AppStore|x64.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.AppStore|x64.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.AppStore|x86.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.AppStore|x86.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Debug|ARM.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Debug|ARM.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Debug|iPhone.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Debug|x64.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Debug|x64.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Debug|x86.ActiveCfg = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Debug|x86.Build.0 = Debug|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Release|Any CPU.Build.0 = Release|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Release|ARM.ActiveCfg = Release|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Release|ARM.Build.0 = Release|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Release|iPhone.ActiveCfg = Release|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Release|iPhone.Build.0 = Release|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Release|x64.ActiveCfg = Release|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Release|x64.Build.0 = Release|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Release|x86.ActiveCfg = Release|Any CPU
{6CBF0D7F-7566-428E-B704-4059A10FFD52}.Release|x86.Build.0 = Release|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.AppStore|ARM.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.AppStore|iPhone.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.AppStore|x64.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.AppStore|x64.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.AppStore|x86.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.AppStore|x86.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Debug|ARM.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Debug|ARM.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Debug|iPhone.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Debug|x64.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Debug|x64.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Debug|x86.ActiveCfg = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Debug|x86.Build.0 = Debug|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Release|Any CPU.Build.0 = Release|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Release|ARM.ActiveCfg = Release|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Release|ARM.Build.0 = Release|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Release|iPhone.ActiveCfg = Release|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Release|iPhone.Build.0 = Release|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Release|x64.ActiveCfg = Release|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Release|x64.Build.0 = Release|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Release|x86.ActiveCfg = Release|Any CPU
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -1862,6 +1966,10 @@ Global
{766D7E92-6AF0-476C-ADD5-282BF4D8C576} = {E279BF0F-7F66-4F3A-A3AB-2CDA66C1CD04}
{68F5041D-51F2-4630-94B6-B49789F5E51A} = {DB0EFB20-B024-4E5E-A75C-52143C131D25}
{56C2EF0B-6BF2-41D9-BE07-6E6D08D06B35} = {68F5041D-51F2-4630-94B6-B49789F5E51A}
{D2D53ADC-5230-4EF4-95B0-31FD734992F6} = {91CF7717-08AB-4E65-B10E-0B426F01E2E8}
{6CBF0D7F-7566-428E-B704-4059A10FFD52} = {D2D53ADC-5230-4EF4-95B0-31FD734992F6}
{71587505-2945-4286-BF0B-BA4C004B0BA7} = {91CF7717-08AB-4E65-B10E-0B426F01E2E8}
{9C101827-119D-44EE-B0F0-94E7ABA8AE6A} = {71587505-2945-4286-BF0B-BA4C004B0BA7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9}


+ 106
- 0
src/Services/TenantManager/TenantManager/Controllers/CustomisationsController.cs View File

@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using TenantManager.Database;
using TenantManager.Models;
namespace TenantManager.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class CustomisationsController : ControllerBase
{
private readonly TenantManagerContext _context;
public CustomisationsController(TenantManagerContext context)
{
_context = context;
}
// GET: api/Customisations
[HttpGet]
public async Task<ActionResult<IEnumerable<Customisation>>> GetCustomisation()
{
return await _context.Customisation.ToListAsync();
}
// GET: api/Customisations/5
[HttpGet("{id}")]
public async Task<ActionResult<Customisation>> GetCustomisation(int id)
{
var customisation = await _context.Customisation.FindAsync(id);
if (customisation == null)
{
return NotFound();
}
return customisation;
}
// PUT: api/Customisations/5
[HttpPut("{id}")]
public async Task<IActionResult> PutCustomisation(int id, Customisation customisation)
{
if (id != customisation.CustomisationId)
{
return BadRequest();
}
_context.Entry(customisation).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!CustomisationExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return NoContent();
}
// POST: api/Customisations
[HttpPost]
public async Task<ActionResult<Customisation>> PostCustomisation(Customisation customisation)
{
_context.Customisation.Add(customisation);
await _context.SaveChangesAsync();
return CreatedAtAction("GetCustomisation", new { id = customisation.CustomisationId }, customisation);
}
// DELETE: api/Customisations/5
[HttpDelete("{id}")]
public async Task<ActionResult<Customisation>> DeleteCustomisation(int id)
{
var customisation = await _context.Customisation.FindAsync(id);
if (customisation == null)
{
return NotFound();
}
_context.Customisation.Remove(customisation);
await _context.SaveChangesAsync();
return customisation;
}
private bool CustomisationExists(int id)
{
return _context.Customisation.Any(e => e.CustomisationId == id);
}
}
}

+ 106
- 0
src/Services/TenantManager/TenantManager/Controllers/MethodsController.cs View File

@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using TenantManager.Database;
using TenantManager.Models;
namespace TenantManager.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class MethodsController : ControllerBase
{
private readonly TenantManagerContext _context;
public MethodsController(TenantManagerContext context)
{
_context = context;
}
// GET: api/Methods
[HttpGet]
public async Task<ActionResult<IEnumerable<Method>>> GetMethod()
{
return await _context.Method.ToListAsync();
}
// GET: api/Methods/5
[HttpGet("{id}")]
public async Task<ActionResult<Method>> GetMethod(int id)
{
var @method = await _context.Method.FindAsync(id);
if (@method == null)
{
return NotFound();
}
return @method;
}
// PUT: api/Methods/5
[HttpPut("{id}")]
public async Task<IActionResult> PutMethod(int id, Method @method)
{
if (id != @method.MethodId)
{
return BadRequest();
}
_context.Entry(@method).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!MethodExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return NoContent();
}
// POST: api/Methods
[HttpPost]
public async Task<ActionResult<Method>> PostMethod(Method @method)
{
_context.Method.Add(@method);
await _context.SaveChangesAsync();
return CreatedAtAction("GetMethod", new { id = @method.MethodId }, @method);
}
// DELETE: api/Methods/5
[HttpDelete("{id}")]
public async Task<ActionResult<Method>> DeleteMethod(int id)
{
var @method = await _context.Method.FindAsync(id);
if (@method == null)
{
return NotFound();
}
_context.Method.Remove(@method);
await _context.SaveChangesAsync();
return @method;
}
private bool MethodExists(int id)
{
return _context.Method.Any(e => e.MethodId == id);
}
}
}

+ 105
- 0
src/Services/TenantManager/TenantManager/Controllers/TenantsController.cs View File

@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using TenantManager.Models;
namespace TenantManager.Database
{
[Route("api/[controller]")]
[ApiController]
public class TenantsController : ControllerBase
{
private readonly TenantManagerContext _context;
public TenantsController(TenantManagerContext context)
{
_context = context;
}
// GET: api/Tenants
[HttpGet]
public async Task<ActionResult<IEnumerable<Tenant>>> GetTenant()
{
return await _context.Tenant.ToListAsync();
}
// GET: api/Tenants/5
[HttpGet("{id}")]
public async Task<ActionResult<Tenant>> GetTenant(long id)
{
var tenant = await _context.Tenant.FindAsync(id);
if (tenant == null)
{
return NotFound();
}
return tenant;
}
// PUT: api/Tenants/5
[HttpPut("{id}")]
public async Task<IActionResult> PutTenant(long id, Tenant tenant)
{
if (id != tenant.TenantId)
{
return BadRequest();
}
_context.Entry(tenant).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!TenantExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return NoContent();
}
// POST: api/Tenants
[HttpPost]
public async Task<ActionResult<Tenant>> PostTenant(Tenant tenant)
{
_context.Tenant.Add(tenant);
await _context.SaveChangesAsync();
return CreatedAtAction("GetTenant", new { id = tenant.TenantId }, tenant);
}
// DELETE: api/Tenants/5
[HttpDelete("{id}")]
public async Task<ActionResult<Tenant>> DeleteTenant(long id)
{
var tenant = await _context.Tenant.FindAsync(id);
if (tenant == null)
{
return NotFound();
}
_context.Tenant.Remove(tenant);
await _context.SaveChangesAsync();
return tenant;
}
private bool TenantExists(long id)
{
return _context.Tenant.Any(e => e.TenantId == id);
}
}
}

+ 45
- 0
src/Services/TenantManager/TenantManager/Controllers/ValuesController.cs View File

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace TenantManager.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
// GET api/values
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/values/5
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
return "value";
}
// POST api/values
[HttpPost]
public void Post([FromBody] string value)
{
}
// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// DELETE api/values/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}

+ 35
- 0
src/Services/TenantManager/TenantManager/Data/TenantManagerContext.cs View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using TenantManager.Models;
namespace TenantManager.Database
{
public class TenantManagerContext : DbContext
{
public TenantManagerContext (DbContextOptions<TenantManagerContext> options)
: base(options)
{
}
public DbSet<TenantManager.Models.Tenant> Tenant { get; set; }
public DbSet<TenantManager.Models.Method> Method { get; set; }
public DbSet<TenantManager.Models.Customisation> Customisation { get; set; }
}
public class TenantManagerContextDesignFactory : IDesignTimeDbContextFactory<TenantManagerContext>
{
public TenantManagerContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<TenantManagerContext>()
.UseSqlServer("Server=.;Initial Catalog=Microsoft.eShopOnContainers.Services.TenantManagerDb;Integrated Security=true");
return new TenantManagerContext(optionsBuilder.Options);
}
}
}

+ 70
- 0
src/Services/TenantManager/TenantManager/Database/DbInitializer.cs View File

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TenantManager.Models;
namespace TenantManager.Database
{
public static class DbInitializer
{
public static void Initialize(TenantManagerContext context)
{
context.Database.EnsureCreated();
if (context.Tenant.Any())
{
return;
}
var tenant1 = new Tenant() { TenantName = "Tekna" };
var tenant2 = new Tenant() { TenantName = "NITO" };
var tenant3 = new Tenant() { TenantName = "LO" };
var tenants = new Tenant[]
{
tenant1,
tenant2,
tenant3
};
foreach(Tenant t in tenants)
{
context.Tenant.Add(t);
}
context.SaveChanges();
var method1 = new Method() { MethodName = "GetPrice" };
var method2 = new Method() { MethodName = "GetItem" };
var methods = new Method[]
{
method1,
method2
};
foreach(Method m in methods)
{
context.Method.Add(m);
}
context.SaveChanges();
var customisations = new Customisation[]
{
new Customisation(){Tenant=tenant1, Method=method1 },
new Customisation(){Tenant=tenant1, Method=method2},
new Customisation(){Tenant=tenant2, Method=method1 }
};
foreach(Customisation c in customisations)
{
context.Add(c);
}
context.SaveChanges();
}
}
}

+ 59
- 0
src/Services/TenantManager/TenantManager/Dockerfile View File

@ -0,0 +1,59 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
WORKDIR /src
# Keep the project list and command dotnet restore identical in all Dockfiles to maximize image cache utilization
COPY eShopOnContainers-ServicesAndWebApps.sln .
COPY docker-compose.dcproj /src/
COPY src/ApiGateways/ApiGw-Base/OcelotApiGw.csproj src/ApiGateways/ApiGw-Base/
COPY src/ApiGateways/Mobile.Bff.Shopping/aggregator/Mobile.Shopping.HttpAggregator.csproj src/ApiGateways/Mobile.Bff.Shopping/aggregator/
COPY src/ApiGateways/Web.Bff.Shopping/aggregator/Web.Shopping.HttpAggregator.csproj src/ApiGateways/Web.Bff.Shopping/aggregator/
COPY src/BuildingBlocks/Devspaces.Support/Devspaces.Support.csproj src/BuildingBlocks/Devspaces.Support/
COPY src/BuildingBlocks/EventBus/EventBus/EventBus.csproj src/BuildingBlocks/EventBus/EventBus/
COPY src/BuildingBlocks/EventBus/EventBus.Tests/EventBus.Tests.csproj src/BuildingBlocks/EventBus/EventBus.Tests/
COPY src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj src/BuildingBlocks/EventBus/EventBusRabbitMQ/
COPY src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj src/BuildingBlocks/EventBus/EventBusServiceBus/
COPY src/BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj src/BuildingBlocks/EventBus/IntegrationEventLogEF/
COPY src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj src/BuildingBlocks/WebHostCustomization/WebHost.Customization/
COPY src/Services/Basket/Basket.API/Basket.API.csproj src/Services/Basket/Basket.API/
COPY src/Services/Basket/Basket.FunctionalTests/Basket.FunctionalTests.csproj src/Services/Basket/Basket.FunctionalTests/
COPY src/Services/Basket/Basket.UnitTests/Basket.UnitTests.csproj src/Services/Basket/Basket.UnitTests/
COPY src/Services/Catalog/Catalog.API/Catalog.API.csproj src/Services/Catalog/Catalog.API/
COPY src/Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj src/Services/Catalog/Catalog.FunctionalTests/
COPY src/Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj src/Services/Catalog/Catalog.UnitTests/
COPY src/Services/Identity/Identity.API/Identity.API.csproj src/Services/Identity/Identity.API/
COPY src/Services/Location/Locations.API/Locations.API.csproj src/Services/Location/Locations.API/
COPY src/Services/Location/Locations.FunctionalTests/Locations.FunctionalTests.csproj src/Services/Location/Locations.FunctionalTests/
COPY src/Services/Marketing/Marketing.API/Marketing.API.csproj src/Services/Marketing/Marketing.API/
COPY src/Services/Marketing/Marketing.FunctionalTests/Marketing.FunctionalTests.csproj src/Services/Marketing/Marketing.FunctionalTests/
COPY src/Services/Ordering/Ordering.API/Ordering.API.csproj src/Services/Ordering/Ordering.API/
COPY src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj src/Services/Ordering/Ordering.BackgroundTasks/
COPY src/Services/Ordering/Ordering.Domain/Ordering.Domain.csproj src/Services/Ordering/Ordering.Domain/
COPY src/Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj src/Services/Ordering/Ordering.FunctionalTests/
COPY src/Services/Ordering/Ordering.Infrastructure/Ordering.Infrastructure.csproj src/Services/Ordering/Ordering.Infrastructure/
COPY src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj src/Services/Ordering/Ordering.SignalrHub/
COPY src/Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj src/Services/Ordering/Ordering.UnitTests/
COPY src/Services/Payment/Payment.API/Payment.API.csproj src/Services/Payment/Payment.API/
COPY src/Services/Webhooks/Webhooks.API/Webhooks.API.csproj src/Services/Webhooks/Webhooks.API/
COPY src/Web/WebhookClient/WebhookClient.csproj src/Web/WebhookClient/
COPY src/Web/WebMVC/WebMVC.csproj src/Web/WebMVC/
COPY src/Web/WebSPA/WebSPA.csproj src/Web/WebSPA/
COPY src/Web/WebStatus/WebStatus.csproj src/Web/WebStatus/
COPY test/ServicesTests/Application.FunctionalTests/Application.FunctionalTests.csproj test/ServicesTests/Application.FunctionalTests/
COPY test/ServicesTests/LoadTest/LoadTest.csproj test/ServicesTests/LoadTest/
RUN dotnet restore eShopOnContainers-ServicesAndWebApps.sln
COPY . .
WORKDIR /src/src/Services/TenantManager/TenantManager
RUN dotnet publish --no-restore -c Release -o /app
FROM build AS publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "TenantManager.dll"]

+ 16
- 0
src/Services/TenantManager/TenantManager/Models/Customisation.cs View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace TenantManager.Models
{
public class Customisation
{
public int CustomisationId { get; set; }
public int TenantId { get; set; }
public virtual Tenant Tenant { get; set; }
public int MethodId { get; set; }
public virtual Method Method { get; set; }
}
}

+ 15
- 0
src/Services/TenantManager/TenantManager/Models/Methods.cs View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace TenantManager.Models
{
public class Method
{
public int MethodId { get; set; }
public String MethodName { get; set; }
public ICollection<Customisation> Customisations { get; set; }
}
}

+ 16
- 0
src/Services/TenantManager/TenantManager/Models/Tenant.cs View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace TenantManager.Models
{
public class Tenant
{
public String TenantName { get; set; }
[Key]
public long TenantId { get; set; }
public ICollection<Customisation> Customisations { get; set; }
}
}

+ 44
- 0
src/Services/TenantManager/TenantManager/Program.cs View File

@ -0,0 +1,44 @@
 using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using TenantManager.Database;
namespace TenantManager
{
public class Program
{
public static void Main(string[] args)
{
var host = CreateWebHostBuilder(args).Build();
using (var scope = host.Services.CreateScope())
{
var services = scope.ServiceProvider;
try
{
var context = services.GetRequiredService<TenantManagerContext>();
DbInitializer.Initialize(context);
}
catch (Exception ex)
{
var logger = services.GetRequiredService<ILogger<Program>>();
logger.LogError(ex, "An error occurred creating the DB.");
}
}
host.Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}
}

+ 42
- 0
src/Services/TenantManager/TenantManager/Properties/launchSettings.json View File

@ -0,0 +1,42 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:62897",
"sslPort": 44318
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"TenantManager": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/api/values",
"environmentVariables": {
"ASPNETCORE_URLS": "https://+:443;http://+:80",
"ASPNETCORE_HTTPS_PORT": "44319"
},
"httpPort": 62898,
"useSSL": true,
"sslPort": 44319
}
}
}

+ 134
- 0
src/Services/TenantManager/TenantManager/Startup.cs View File

@ -0,0 +1,134 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.EntityFrameworkCore;
using TenantManager.Database;
using Microsoft.EntityFrameworkCore.Diagnostics;
using System.Reflection;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
namespace TenantManager
{
public static class CustomExtensionMethods
{
public static IServiceCollection AddCustomDbContext(this IServiceCollection services, IConfiguration configuration)
{
services.AddDbContext<TenantManagerContext>(options =>
options.UseSqlServer(configuration["ConnectionString"]));
//services.AddDbContext<TenantManagerContext>(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: 10, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
// });
// // Changing default behavior when client evaluation occurs to throw.
// // Default in EF Core would be to log a warning when client evaluation is performed.
// options.ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning));
// //Check Client vs. Server evaluation: https://docs.microsoft.com/en-us/ef/core/querying/client-eval
//});
return services;
}
public static IServiceCollection AddCustomMvc(this IServiceCollection services)
{
// Add framework services.
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
.AddControllersAsServices(); //Injecting Controllers themselves thru DI
//For further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder
.SetIsOriginAllowed((host) => true)
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
});
return services;
}
public static IServiceCollection AddCustomConfiguration(this IServiceCollection services, IConfiguration configuration)
{
services.AddOptions();
services.Configure<TenantManagerSettings>(configuration);
services.Configure<ApiBehaviorOptions>(options =>
{
options.InvalidModelStateResponseFactory = context =>
{
var problemDetails = new ValidationProblemDetails(context.ModelState)
{
Instance = context.HttpContext.Request.Path,
Status = StatusCodes.Status400BadRequest,
Detail = "Please refer to the errors property for additional details."
};
return new BadRequestObjectResult(problemDetails)
{
ContentTypes = { "application/problem+json", "application/problem+xml" }
};
};
});
return services;
}
}
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services
.AddCustomDbContext(Configuration)
.AddCustomMvc()
.AddCustomConfiguration(Configuration);
var container = new ContainerBuilder();
container.Populate(services);
return new AutofacServiceProvider(container.Build());
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseMvc();
}
}
}

+ 25
- 0
src/Services/TenantManager/TenantManager/TenantManager.csproj View File

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<UserSecretsId>32cd2988-8f43-4aff-88af-6a3397a7d2e6</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.6.2" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.6" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.7.12" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="Infrastructure\Filters\" />
</ItemGroup>
</Project>

+ 13
- 0
src/Services/TenantManager/TenantManager/TenantManagerSettings.cs View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace TenantManager
{
public class TenantManagerSettings
{
public string ConnectionString { get; set; }
}
}

+ 9
- 0
src/Services/TenantManager/TenantManager/appsettings.Development.json View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}

+ 9
- 0
src/Services/TenantManager/TenantManager/appsettings.json View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionString": "Server=tcp:127.0.0.1,5433;Database=Microsoft.eShopOnContainers.Services.TenantManagerDb;User Id=sa;Password=Pass@word;"
}

Loading…
Cancel
Save