Browse Source

Consolidated redundant code

pull/493/head
Robert Raboud 7 years ago
parent
commit
0228082396
64 changed files with 546 additions and 1126 deletions
  1. +163
    -1
      eShopOnContainers.sln
  2. +3
    -2
      src/BuildingBlocks/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs
  3. +1
    -1
      src/BuildingBlocks/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs
  4. +13
    -19
      src/BuildingBlocks/Infrastructure/Filters/HttpGlobalExceptionFilter.cs
  5. +2
    -2
      src/BuildingBlocks/Infrastructure/Filters/JsonErrorResponse.cs
  6. +1
    -1
      src/BuildingBlocks/Infrastructure/Filters/ValidateModelStateFilter.cs
  7. +25
    -0
      src/BuildingBlocks/Infrastructure/Infrastructure.csproj
  8. +3
    -4
      src/BuildingBlocks/Infrastructure/Middlewares/ByPassAuthMiddleware.cs
  9. +1
    -1
      src/BuildingBlocks/Linq/Microsoft.Extensions.Linq/LinqSelectExtensions.cs
  10. +7
    -0
      src/BuildingBlocks/Linq/Microsoft.Extensions.Linq/Microsoft.Extensions.Linq.csproj
  11. +18
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Resources/Resource.Designer.cs
  12. +18
    -0
      src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/Resources/Resource.Designer.cs
  13. +6
    -0
      src/Services/Basket/Basket.API/Basket.API.csproj
  14. +0
    -56
      src/Services/Basket/Basket.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs
  15. +4
    -2
      src/Services/Basket/Basket.API/Startup.cs
  16. +9
    -0
      src/Services/Catalog/Catalog.API/Catalog.API.csproj
  17. +1
    -1
      src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs
  18. +0
    -50
      src/Services/Catalog/Catalog.API/Extensions/LinqSelectExtensions.cs
  19. +0
    -14
      src/Services/Catalog/Catalog.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs
  20. +17
    -17
      src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs
  21. +0
    -63
      src/Services/Catalog/Catalog.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs
  22. +33
    -32
      src/Services/Catalog/Catalog.API/Startup.cs
  23. +0
    -24
      src/Services/Catalog/Catalog.API/ViewModel/PaginatedItemsViewModel.cs
  24. +9
    -0
      src/Services/Common/Common.API/Common.API.csproj
  25. +25
    -0
      src/Services/Common/Common.API/PaginatedItemsViewModel.cs
  26. +1
    -1
      src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs
  27. +0
    -50
      src/Services/Identity/Identity.API/Extensions/LinqSelectExtensions.cs
  28. +1
    -4
      src/Services/Identity/Identity.API/Identity.API.csproj
  29. +0
    -14
      src/Services/Location/Locations.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs
  30. +0
    -31
      src/Services/Location/Locations.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs
  31. +0
    -67
      src/Services/Location/Locations.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs
  32. +0
    -79
      src/Services/Location/Locations.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs
  33. +4
    -0
      src/Services/Location/Locations.API/Locations.API.csproj
  34. +4
    -3
      src/Services/Location/Locations.API/Startup.cs
  35. +16
    -18
      src/Services/Marketing/Marketing.API/Controllers/CampaignsController.cs
  36. +0
    -14
      src/Services/Marketing/Marketing.API/Infrastructure/ActionResult/InternalServerErrorObjectResult.cs
  37. +0
    -32
      src/Services/Marketing/Marketing.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs
  38. +0
    -67
      src/Services/Marketing/Marketing.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs
  39. +0
    -78
      src/Services/Marketing/Marketing.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs
  40. +3
    -0
      src/Services/Marketing/Marketing.API/Marketing.API.csproj
  41. +37
    -36
      src/Services/Marketing/Marketing.API/Startup.cs
  42. +0
    -23
      src/Services/Marketing/Marketing.API/ViewModel/PaginatedItemsViewModel.cs
  43. +0
    -14
      src/Services/Ordering/Ordering.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs
  44. +0
    -32
      src/Services/Ordering/Ordering.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs
  45. +0
    -79
      src/Services/Ordering/Ordering.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs
  46. +20
    -19
      src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs
  47. +6
    -0
      src/Services/Ordering/Ordering.API/Ordering.API.csproj
  48. +40
    -39
      src/Services/Ordering/Ordering.API/Startup.cs
  49. +6
    -0
      src/Web/WebMVC/ByPassAuthMiddleware.cs
  50. +3
    -2
      src/Web/WebMVC/Controllers/CampaignsController.cs
  51. +2
    -1
      src/Web/WebMVC/Controllers/CatalogController.cs
  52. +0
    -80
      src/Web/WebMVC/Infrastructure/Middlewares/ByPassAuthMiddleware.cs
  53. +4
    -3
      src/Web/WebMVC/Services/CampaignService.cs
  54. +3
    -2
      src/Web/WebMVC/Services/CatalogService.cs
  55. +3
    -2
      src/Web/WebMVC/Services/ICampaignService.cs
  56. +2
    -1
      src/Web/WebMVC/Services/ICatalogService.cs
  57. +0
    -1
      src/Web/WebMVC/Startup.cs
  58. +0
    -12
      src/Web/WebMVC/ViewModels/Campaign.cs
  59. +1
    -1
      src/Web/WebMVC/ViewModels/Pagination/PaginationInfo.cs
  60. +5
    -0
      src/Web/WebMVC/WebMVC.csproj
  61. +1
    -0
      src/Web/WebSPA/WebSPA.csproj
  62. +1
    -1
      test/Services/FunctionalTests/Services/IntegrationEventsScenarios.cs
  63. +0
    -1
      test/Services/FunctionalTests/Services/Marketing/MarketingScenarios.cs
  64. +24
    -29
      test/Services/UnitTest/Catalog/Application/CatalogControllerTest.cs

+ 163
- 1
eShopOnContainers.sln View File

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio 15
VisualStudioVersion = 15.0.27130.2024
VisualStudioVersion = 15.0.27130.2027
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{FEA0C318-FFED-4D39-8781-265718CA43DD}" Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{FEA0C318-FFED-4D39-8781-265718CA43DD}"
EndProject EndProject
@ -123,6 +123,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eShopOnContainers.TestRunne
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ordering.BackgroundTasks", "src\Services\Ordering\Ordering.BackgroundTasks\Ordering.BackgroundTasks.csproj", "{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ordering.BackgroundTasks", "src\Services\Ordering\Ordering.BackgroundTasks\Ordering.BackgroundTasks.csproj", "{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.API", "src\Services\Common\Common.API\Common.API.csproj", "{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{9739C2F5-67BF-4F42-B415-D08739DF82BB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{181C11A7-689F-4353-8406-92B1D27C0DE3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Linq", "Linq", "{56A37793-C885-4599-930D-4210618FD56F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Infrastructure", "src\BuildingBlocks\Infrastructure\Infrastructure.csproj", "{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Linq", "src\BuildingBlocks\Linq\Microsoft.Extensions.Linq\Microsoft.Extensions.Linq.csproj", "{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
@ -1809,6 +1821,150 @@ Global
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|x64.Build.0 = Release|Any CPU {16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|x64.Build.0 = Release|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|x86.ActiveCfg = Release|Any CPU {16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|x86.ActiveCfg = Release|Any CPU
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|x86.Build.0 = Release|Any CPU {16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}.Release|x86.Build.0 = Release|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.AppStore|ARM.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.AppStore|iPhone.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.AppStore|x64.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.AppStore|x64.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.AppStore|x86.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.AppStore|x86.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Debug|ARM.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Debug|ARM.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Debug|iPhone.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Debug|x64.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Debug|x64.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Debug|x86.ActiveCfg = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Debug|x86.Build.0 = Debug|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Release|Any CPU.Build.0 = Release|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Release|ARM.ActiveCfg = Release|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Release|ARM.Build.0 = Release|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Release|iPhone.ActiveCfg = Release|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Release|iPhone.Build.0 = Release|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Release|x64.ActiveCfg = Release|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Release|x64.Build.0 = Release|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Release|x86.ActiveCfg = Release|Any CPU
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66}.Release|x86.Build.0 = Release|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.AppStore|ARM.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.AppStore|iPhone.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.AppStore|x64.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.AppStore|x64.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.AppStore|x86.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.AppStore|x86.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Debug|ARM.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Debug|ARM.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Debug|iPhone.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Debug|x64.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Debug|x64.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Debug|x86.ActiveCfg = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Debug|x86.Build.0 = Debug|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Release|Any CPU.Build.0 = Release|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Release|ARM.ActiveCfg = Release|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Release|ARM.Build.0 = Release|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Release|iPhone.ActiveCfg = Release|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Release|iPhone.Build.0 = Release|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Release|x64.ActiveCfg = Release|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Release|x64.Build.0 = Release|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Release|x86.ActiveCfg = Release|Any CPU
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E}.Release|x86.Build.0 = Release|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.AppStore|ARM.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.AppStore|iPhone.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.AppStore|x64.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.AppStore|x64.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.AppStore|x86.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.AppStore|x86.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Debug|ARM.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Debug|ARM.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Debug|iPhone.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Debug|x64.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Debug|x64.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Debug|x86.ActiveCfg = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Debug|x86.Build.0 = Debug|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Release|Any CPU.Build.0 = Release|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Release|ARM.ActiveCfg = Release|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Release|ARM.Build.0 = Release|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Release|iPhone.ActiveCfg = Release|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Release|iPhone.Build.0 = Release|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Release|x64.ActiveCfg = Release|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Release|x64.Build.0 = Release|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Release|x86.ActiveCfg = Release|Any CPU
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -1868,6 +2024,12 @@ Global
{B68C2B56-7581-46AE-B55D-D25DDFD3BFE3} = {0AAED9FF-3260-43BB-B586-9AAF1E010A90} {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3} = {0AAED9FF-3260-43BB-B586-9AAF1E010A90}
{A7337243-33B8-463A-87AD-944B75EFD820} = {0AAED9FF-3260-43BB-B586-9AAF1E010A90} {A7337243-33B8-463A-87AD-944B75EFD820} = {0AAED9FF-3260-43BB-B586-9AAF1E010A90}
{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480} = {0BD0DB92-2D98-44D9-9AC0-C59186D59B0B} {16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480} = {0BD0DB92-2D98-44D9-9AC0-C59186D59B0B}
{7AB9E95E-8C48-4F92-AD23-0327F9D1AF66} = {9739C2F5-67BF-4F42-B415-D08739DF82BB}
{9739C2F5-67BF-4F42-B415-D08739DF82BB} = {91CF7717-08AB-4E65-B10E-0B426F01E2E8}
{181C11A7-689F-4353-8406-92B1D27C0DE3} = {DB0EFB20-B024-4E5E-A75C-52143C131D25}
{56A37793-C885-4599-930D-4210618FD56F} = {DB0EFB20-B024-4E5E-A75C-52143C131D25}
{D1DD672B-7AE6-4B7A-9D83-F2CB03D60A5E} = {181C11A7-689F-4353-8406-92B1D27C0DE3}
{2465E200-CB7D-4F38-BD74-19FC9BBE30B6} = {56A37793-C885-4599-930D-4210618FD56F}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9} SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9}


src/Services/Basket/Basket.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs → src/BuildingBlocks/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs View File

@ -1,8 +1,9 @@
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace Basket.API.Infrastructure.ActionResults
namespace Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.ActionResults
{ {
public class InternalServerErrorObjectResult : ObjectResult public class InternalServerErrorObjectResult : ObjectResult
{ {
public InternalServerErrorObjectResult(object error) public InternalServerErrorObjectResult(object error)
@ -11,4 +12,4 @@ namespace Basket.API.Infrastructure.ActionResults
StatusCode = StatusCodes.Status500InternalServerError; StatusCode = StatusCodes.Status500InternalServerError;
} }
} }
}
}

src/Services/Basket/Basket.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs → src/BuildingBlocks/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs View File

@ -4,7 +4,7 @@ using Swashbuckle.AspNetCore.SwaggerGen;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace Basket.API.Infrastructure.Filters
namespace Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Filters
{ {
public class AuthorizeCheckOperationFilter : IOperationFilter public class AuthorizeCheckOperationFilter : IOperationFilter
{ {

src/Services/Ordering/Ordering.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs → src/BuildingBlocks/Infrastructure/Filters/HttpGlobalExceptionFilter.cs View File

@ -1,19 +1,19 @@
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Filters
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.ActionResults;
using Microsoft.Extensions.Logging;
using System.Net;
namespace Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Filters
{ {
using AspNetCore.Mvc;
using global::Ordering.Domain.Exceptions;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.ActionResults;
using Microsoft.Extensions.Logging;
using System.Net;
public class HttpGlobalExceptionFilter : IExceptionFilter
public class HttpGlobalExceptionFilter<T> : IExceptionFilter
{ {
private readonly IHostingEnvironment env; private readonly IHostingEnvironment env;
private readonly ILogger<HttpGlobalExceptionFilter> logger;
private readonly ILogger<HttpGlobalExceptionFilter<T>> logger;
public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger<HttpGlobalExceptionFilter> logger)
public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger<HttpGlobalExceptionFilter<T>> logger)
{ {
this.env = env; this.env = env;
this.logger = logger; this.logger = logger;
@ -25,7 +25,7 @@
context.Exception, context.Exception,
context.Exception.Message); context.Exception.Message);
if (context.Exception.GetType() == typeof(OrderingDomainException))
if (context.Exception.GetType() == typeof(T))
{ {
var json = new JsonErrorResponse var json = new JsonErrorResponse
{ {
@ -57,11 +57,5 @@
context.ExceptionHandled = true; context.ExceptionHandled = true;
} }
private class JsonErrorResponse
{
public string[] Messages { get; set; }
public object DeveloperMessage { get; set; }
}
} }
}
}

src/Services/Basket/Basket.API/Infrastructure/Filters/JsonErrorResponse.cs → src/BuildingBlocks/Infrastructure/Filters/JsonErrorResponse.cs View File

@ -1,6 +1,6 @@
namespace Basket.API.Infrastructure.Filters
namespace Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Filters
{ {
public class JsonErrorResponse
public class JsonErrorResponse
{ {
public string[] Messages { get; set; } public string[] Messages { get; set; }

src/Services/Basket/Basket.API/Infrastructure/Filters/ValidateModelStateFilter.cs → src/BuildingBlocks/Infrastructure/Filters/ValidateModelStateFilter.cs View File

@ -2,7 +2,7 @@
using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Filters;
using System.Linq; using System.Linq;
namespace Basket.API.Infrastructure.Filters
namespace Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Filters
{ {
public class ValidateModelStateFilter : ActionFilterAttribute public class ValidateModelStateFilter : ActionFilterAttribute
{ {

+ 25
- 0
src/BuildingBlocks/Infrastructure/Infrastructure.csproj View File

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RootNamespace>Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Hosting.Abstractions">
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.hosting.abstractions\2.0.1\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNetCore.Mvc.Abstractions">
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.abstractions\2.0.2\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.logging.abstractions\2.0.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

src/Services/Basket/Basket.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs → src/BuildingBlocks/Infrastructure/Middlewares/ByPassAuthMiddleware.cs View File

@ -1,14 +1,13 @@
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives; using Microsoft.Extensions.Primitives;
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Claims; using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Basket.API.Infrastructure.Middlewares
namespace Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Middlewares
{ {
class ByPassAuthMiddleware
public class ByPassAuthMiddleware
{ {
private readonly RequestDelegate _next; private readonly RequestDelegate _next;
private string _currentUserId; private string _currentUserId;
@ -64,8 +63,8 @@ namespace Basket.API.Infrastructure.Middlewares
new Claim("nonce", Guid.NewGuid().ToString()), new Claim("nonce", Guid.NewGuid().ToString()),
new Claim("ttp://schemas.microsoft.com/identity/claims/identityprovider", "ByPassAuthMiddleware"), new Claim("ttp://schemas.microsoft.com/identity/claims/identityprovider", "ByPassAuthMiddleware"),
new Claim("nonce", Guid.NewGuid().ToString()), new Claim("nonce", Guid.NewGuid().ToString()),
new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname","User"),
new Claim("sub", "1234"), new Claim("sub", "1234"),
new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname","User"),
new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname","Microsoft")} new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname","Microsoft")}
, "ByPassAuth"); , "ByPassAuth");

src/Services/Ordering/Ordering.API/Extensions/LinqSelectExtensions.cs → src/BuildingBlocks/Linq/Microsoft.Extensions.Linq/LinqSelectExtensions.cs View File

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace Ordering.API.Extensions
namespace Microsoft.Extensions.Linq
{ {
public static class LinqSelectExtensions public static class LinqSelectExtensions
{ {

+ 7
- 0
src/BuildingBlocks/Linq/Microsoft.Extensions.Linq/Microsoft.Extensions.Linq.csproj View File

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>

+ 18
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Resources/Resource.Designer.cs View File

@ -2274,9 +2274,27 @@ namespace eShopOnContainers.Droid
// aapt resource value: 0x7f020054 // aapt resource value: 0x7f020054
public const int avd_hide_password = 2130837588; public const int avd_hide_password = 2130837588;
// aapt resource value: 0x7f020127
public const int avd_hide_password_1 = 2130837799;
// aapt resource value: 0x7f020128
public const int avd_hide_password_2 = 2130837800;
// aapt resource value: 0x7f020129
public const int avd_hide_password_3 = 2130837801;
// aapt resource value: 0x7f020055 // aapt resource value: 0x7f020055
public const int avd_show_password = 2130837589; public const int avd_show_password = 2130837589;
// aapt resource value: 0x7f02012a
public const int avd_show_password_1 = 2130837802;
// aapt resource value: 0x7f02012b
public const int avd_show_password_2 = 2130837803;
// aapt resource value: 0x7f02012c
public const int avd_show_password_3 = 2130837804;
// aapt resource value: 0x7f020056 // aapt resource value: 0x7f020056
public const int background = 2130837590; public const int background = 2130837590;


+ 18
- 0
src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/Resources/Resource.Designer.cs View File

@ -2268,9 +2268,27 @@ namespace eShopOnContainers.TestRunner.Droid
// aapt resource value: 0x7f020053 // aapt resource value: 0x7f020053
public const int avd_hide_password = 2130837587; public const int avd_hide_password = 2130837587;
// aapt resource value: 0x7f020112
public const int avd_hide_password_1 = 2130837778;
// aapt resource value: 0x7f020113
public const int avd_hide_password_2 = 2130837779;
// aapt resource value: 0x7f020114
public const int avd_hide_password_3 = 2130837780;
// aapt resource value: 0x7f020054 // aapt resource value: 0x7f020054
public const int avd_show_password = 2130837588; public const int avd_show_password = 2130837588;
// aapt resource value: 0x7f020115
public const int avd_show_password_1 = 2130837781;
// aapt resource value: 0x7f020116
public const int avd_show_password_2 = 2130837782;
// aapt resource value: 0x7f020117
public const int avd_show_password_3 = 2130837783;
// aapt resource value: 0x7f020055 // aapt resource value: 0x7f020055
public const int design_bottom_navigation_item_background = 2130837589; public const int design_bottom_navigation_item_background = 2130837589;


+ 6
- 0
src/Services/Basket/Basket.API/Basket.API.csproj View File

@ -28,6 +28,12 @@
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\Infrastructure\Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Infrastructure\ActionResults\" />
<Folder Include="Infrastructure\Filters\" />
</ItemGroup> </ItemGroup>
</Project> </Project>

+ 0
- 56
src/Services/Basket/Basket.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs View File

@ -1,56 +0,0 @@
using Basket.API.Infrastructure.ActionResults;
using Basket.API.Infrastructure.Exceptions;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using System.Net;
namespace Basket.API.Infrastructure.Filters
{
public partial class HttpGlobalExceptionFilter : IExceptionFilter
{
private readonly IHostingEnvironment env;
private readonly ILogger<HttpGlobalExceptionFilter> logger;
public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger<HttpGlobalExceptionFilter> logger)
{
this.env = env;
this.logger = logger;
}
public void OnException(ExceptionContext context)
{
logger.LogError(new EventId(context.Exception.HResult),
context.Exception,
context.Exception.Message);
if (context.Exception.GetType() == typeof(BasketDomainException))
{
var json = new JsonErrorResponse
{
Messages = new[] { context.Exception.Message }
};
context.Result = new BadRequestObjectResult(json);
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
}
else
{
var json = new JsonErrorResponse
{
Messages = new[] { "An error occurred. Try it again." }
};
if (env.IsDevelopment())
{
json.DeveloperMessage = context.Exception;
}
context.Result = new InternalServerErrorObjectResult(json);
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
}
context.ExceptionHandled = true;
}
}
}

+ 4
- 2
src/Services/Basket/Basket.API/Startup.cs View File

@ -1,6 +1,6 @@
using Autofac; using Autofac;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
using Basket.API.Infrastructure.Filters;
using Basket.API.Infrastructure.Exceptions;
using Basket.API.Infrastructure.Middlewares; using Basket.API.Infrastructure.Middlewares;
using Basket.API.IntegrationEvents.EventHandling; using Basket.API.IntegrationEvents.EventHandling;
using Basket.API.IntegrationEvents.Events; using Basket.API.IntegrationEvents.Events;
@ -15,6 +15,8 @@ using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ; using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus; using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
using Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Filters;
using Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Middlewares;
using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.EventHandling; using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.EventHandling;
using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Events; using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Events;
using Microsoft.eShopOnContainers.Services.Basket.API.Model; using Microsoft.eShopOnContainers.Services.Basket.API.Model;
@ -52,7 +54,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
// Add framework services. // Add framework services.
services.AddMvc(options => services.AddMvc(options =>
{ {
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
options.Filters.Add(typeof(HttpGlobalExceptionFilter<BasketDomainException>));
options.Filters.Add(typeof(ValidateModelStateFilter)); options.Filters.Add(typeof(ValidateModelStateFilter));
}).AddControllersAsServices(); }).AddControllersAsServices();


+ 9
- 0
src/Services/Catalog/Catalog.API/Catalog.API.csproj View File

@ -57,7 +57,10 @@
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.SqlServer\Microsoft.Extensions.HealthChecks.SqlServer.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.SqlServer\Microsoft.Extensions.HealthChecks.SqlServer.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\IntegrationEventLogEF\IntegrationEventLogEF.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\EventBus\IntegrationEventLogEF\IntegrationEventLogEF.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\Infrastructure\Infrastructure.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\Linq\Microsoft.Extensions.Linq\Microsoft.Extensions.Linq.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\WebHostCustomization\WebHost.Customization\WebHost.Customization.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\WebHostCustomization\WebHost.Customization\WebHost.Customization.csproj" />
<ProjectReference Include="..\..\Common\Common.API\Common.API.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -69,4 +72,10 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Infrastructure\ActionResults\" />
<Folder Include="Infrastructure\Filters\" />
<Folder Include="ViewModel\" />
</ItemGroup>
</Project> </Project>

+ 1
- 1
src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs View File

@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events; using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events;
using Microsoft.eShopOnContainers.Services.Catalog.API.Model; using Microsoft.eShopOnContainers.Services.Catalog.API.Model;
using Microsoft.eShopOnContainers.Services.Catalog.API.ViewModel;
using Microsoft.eShopOnContainers.Services.Common.API;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;


+ 0
- 50
src/Services/Catalog/Catalog.API/Extensions/LinqSelectExtensions.cs View File

@ -1,50 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Catalog.API.Extensions
{
public static class LinqSelectExtensions
{
public static IEnumerable<SelectTryResult<TSource, TResult>> SelectTry<TSource, TResult>(this IEnumerable<TSource> enumerable, Func<TSource, TResult> selector)
{
foreach (TSource element in enumerable)
{
SelectTryResult<TSource, TResult> returnedValue;
try
{
returnedValue = new SelectTryResult<TSource, TResult>(element, selector(element), null);
}
catch (Exception ex)
{
returnedValue = new SelectTryResult<TSource, TResult>(element, default(TResult), ex);
}
yield return returnedValue;
}
}
public static IEnumerable<TResult> OnCaughtException<TSource, TResult>(this IEnumerable<SelectTryResult<TSource, TResult>> enumerable, Func<Exception, TResult> exceptionHandler)
{
return enumerable.Select(x => x.CaughtException == null ? x.Result : exceptionHandler(x.CaughtException));
}
public static IEnumerable<TResult> OnCaughtException<TSource, TResult>(this IEnumerable<SelectTryResult<TSource, TResult>> enumerable, Func<TSource, Exception, TResult> exceptionHandler)
{
return enumerable.Select(x => x.CaughtException == null ? x.Result : exceptionHandler(x.Source, x.CaughtException));
}
public class SelectTryResult<TSource, TResult>
{
internal SelectTryResult(TSource source, TResult result, Exception exception)
{
Source = source;
Result = result;
CaughtException = exception;
}
public TSource Source { get; private set; }
public TResult Result { get; private set; }
public Exception CaughtException { get; private set; }
}
}
}

+ 0
- 14
src/Services/Catalog/Catalog.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs View File

@ -1,14 +0,0 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Catalog.API.Infrastructure.ActionResults
{
public class InternalServerErrorObjectResult : ObjectResult
{
public InternalServerErrorObjectResult(object error)
: base(error)
{
StatusCode = StatusCodes.Status500InternalServerError;
}
}
}

+ 17
- 17
src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs View File

@ -1,21 +1,21 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure
using Microsoft.AspNetCore.Hosting;
using Microsoft.eShopOnContainers.Services.Catalog.API.Model;
using Microsoft.Extensions.Linq;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Polly;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure
{ {
using Extensions.Logging;
using global::Catalog.API.Extensions;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Options;
using Model;
using Polly;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
public class CatalogContextSeed public class CatalogContextSeed
{ {
public async Task SeedAsync(CatalogContext context,IHostingEnvironment env,IOptions<CatalogSettings> settings,ILogger<CatalogContextSeed> logger) public async Task SeedAsync(CatalogContext context,IHostingEnvironment env,IOptions<CatalogSettings> settings,ILogger<CatalogContextSeed> logger)


+ 0
- 63
src/Services/Catalog/Catalog.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs View File

@ -1,63 +0,0 @@
using Catalog.API.Infrastructure.ActionResults;
using Catalog.API.Infrastructure.Exceptions;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using System.Net;
namespace Catalog.API.Infrastructure.Filters
{
public class HttpGlobalExceptionFilter : IExceptionFilter
{
private readonly IHostingEnvironment env;
private readonly ILogger<HttpGlobalExceptionFilter> logger;
public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger<HttpGlobalExceptionFilter> logger)
{
this.env = env;
this.logger = logger;
}
public void OnException(ExceptionContext context)
{
logger.LogError(new EventId(context.Exception.HResult),
context.Exception,
context.Exception.Message);
if (context.Exception.GetType() == typeof(CatalogDomainException))
{
var json = new JsonErrorResponse
{
Messages = new[] { context.Exception.Message }
};
context.Result = new BadRequestObjectResult(json);
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
}
else
{
var json = new JsonErrorResponse
{
Messages = new[] { "An error ocurr.Try it again." }
};
if (env.IsDevelopment())
{
json.DeveloperMeesage = context.Exception;
}
context.Result = new InternalServerErrorObjectResult(json);
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
}
context.ExceptionHandled = true;
}
private class JsonErrorResponse
{
public string[] Messages { get; set; }
public object DeveloperMeesage { get; set; }
}
}
}

+ 33
- 32
src/Services/Catalog/Catalog.API/Startup.cs View File

@ -1,35 +1,36 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Catalog.API.Infrastructure.Exceptions;
using Catalog.API.IntegrationEvents;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.ServiceFabric;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Azure.ServiceBus;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
using Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Filters;
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling;
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.HealthChecks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using RabbitMQ.Client;
using System;
using System.Data.Common;
using System.Reflection;
namespace Microsoft.eShopOnContainers.Services.Catalog.API
{ {
using Autofac;
using Autofac.Extensions.DependencyInjection;
using global::Catalog.API.Infrastructure.Filters;
using global::Catalog.API.IntegrationEvents;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.ServiceFabric;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Azure.ServiceBus;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling;
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.HealthChecks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using RabbitMQ.Client;
using System;
using System.Data.Common;
using System.Reflection;
public class Startup public class Startup
{ {
public Startup(IConfiguration configuration) public Startup(IConfiguration configuration)
@ -64,7 +65,7 @@
services.AddMvc(options => services.AddMvc(options =>
{ {
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
options.Filters.Add(typeof(HttpGlobalExceptionFilter<CatalogDomainException>));
}).AddControllersAsServices(); }).AddControllersAsServices();
services.AddDbContext<CatalogContext>(options => services.AddDbContext<CatalogContext>(options =>


+ 0
- 24
src/Services/Catalog/Catalog.API/ViewModel/PaginatedItemsViewModel.cs View File

@ -1,24 +0,0 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.ViewModel
{
using System.Collections.Generic;
public class PaginatedItemsViewModel<TEntity> where TEntity : class
{
public int PageIndex { get; private set; }
public int PageSize { get; private set; }
public long Count { get; private set; }
public IEnumerable<TEntity> Data { get; private set; }
public PaginatedItemsViewModel(int pageIndex, int pageSize, long count, IEnumerable<TEntity> data)
{
this.PageIndex = pageIndex;
this.PageSize = pageSize;
this.Count = count;
this.Data = data;
}
}
}

+ 9
- 0
src/Services/Common/Common.API/Common.API.csproj View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Common.API</AssemblyName>
<RootNamespace>Microsoft.eShopOnContainers.Services.Common.API</RootNamespace>
</PropertyGroup>
</Project>

+ 25
- 0
src/Services/Common/Common.API/PaginatedItemsViewModel.cs View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.eShopOnContainers.Services.Common.API
{
public class PaginatedItemsViewModel<TEntity> where TEntity : class
{
public int PageIndex { get; private set; }
public int PageSize { get; private set; }
public long Count { get; private set; }
public IEnumerable<TEntity> Data { get; private set; }
public PaginatedItemsViewModel(int pageIndex, int pageSize, long count, IEnumerable<TEntity> data)
{
this.PageIndex = pageIndex;
this.PageSize = pageSize;
this.Count = count;
this.Data = data;
}
}
}

+ 1
- 1
src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs View File

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.eShopOnContainers.Services.Identity.API.Extensions;
using Microsoft.Extensions.Linq;
using Microsoft.eShopOnContainers.Services.Identity.API.Models; using Microsoft.eShopOnContainers.Services.Identity.API.Models;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;


+ 0
- 50
src/Services/Identity/Identity.API/Extensions/LinqSelectExtensions.cs View File

@ -1,50 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Extensions
{
public static class LinqSelectExtensions
{
public static IEnumerable<SelectTryResult<TSource, TResult>> SelectTry<TSource, TResult>(this IEnumerable<TSource> enumerable, Func<TSource, TResult> selector)
{
foreach (TSource element in enumerable)
{
SelectTryResult<TSource, TResult> returnedValue;
try
{
returnedValue = new SelectTryResult<TSource, TResult>(element, selector(element), null);
}
catch (Exception ex)
{
returnedValue = new SelectTryResult<TSource, TResult>(element, default(TResult), ex);
}
yield return returnedValue;
}
}
public static IEnumerable<TResult> OnCaughtException<TSource, TResult>(this IEnumerable<SelectTryResult<TSource, TResult>> enumerable, Func<Exception, TResult> exceptionHandler)
{
return enumerable.Select(x => x.CaughtException == null ? x.Result : exceptionHandler(x.CaughtException));
}
public static IEnumerable<TResult> OnCaughtException<TSource, TResult>(this IEnumerable<SelectTryResult<TSource, TResult>> enumerable, Func<TSource, Exception, TResult> exceptionHandler)
{
return enumerable.Select(x => x.CaughtException == null ? x.Result : exceptionHandler(x.Source, x.CaughtException));
}
public class SelectTryResult<TSource, TResult>
{
internal SelectTryResult(TSource source, TResult result, Exception exception)
{
Source = source;
Result = result;
CaughtException = exception;
}
public TSource Source { get; private set; }
public TResult Result { get; private set; }
public Exception CaughtException { get; private set; }
}
}
}

+ 1
- 4
src/Services/Identity/Identity.API/Identity.API.csproj View File

@ -46,6 +46,7 @@
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.SqlServer\Microsoft.Extensions.HealthChecks.SqlServer.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.SqlServer\Microsoft.Extensions.HealthChecks.SqlServer.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\Linq\Microsoft.Extensions.Linq\Microsoft.Extensions.Linq.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\WebHostCustomization\WebHost.Customization\WebHost.Customization.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\WebHostCustomization\WebHost.Customization\WebHost.Customization.csproj" />
</ItemGroup> </ItemGroup>
@ -55,8 +56,4 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Extensions\" />
</ItemGroup>
</Project> </Project>

+ 0
- 14
src/Services/Location/Locations.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs View File

@ -1,14 +0,0 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.ActionResults
{
public class InternalServerErrorObjectResult : ObjectResult
{
public InternalServerErrorObjectResult(object error)
: base(error)
{
StatusCode = StatusCodes.Status500InternalServerError;
}
}
}

+ 0
- 31
src/Services/Location/Locations.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs View File

@ -1,31 +0,0 @@

using Microsoft.AspNetCore.Authorization;
using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Filters
{
internal class AuthorizeCheckOperationFilter : IOperationFilter
{
public void Apply(Operation operation, OperationFilterContext context)
{
// Check for authorize attribute
var hasAuthorize = context.ApiDescription.ControllerAttributes().OfType<AuthorizeAttribute>().Any() ||
context.ApiDescription.ActionAttributes().OfType<AuthorizeAttribute>().Any();
if (hasAuthorize)
{
operation.Responses.Add("401", new Response { Description = "Unauthorized" });
operation.Responses.Add("403", new Response { Description = "Forbidden" });
operation.Security = new List<IDictionary<string, IEnumerable<string>>>();
operation.Security.Add(new Dictionary<string, IEnumerable<string>>
{
{ "oauth2", new [] { "locationsapi" } }
});
}
}
}
}

+ 0
- 67
src/Services/Location/Locations.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs View File

@ -1,67 +0,0 @@
namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Filters
{
using AspNetCore.Mvc;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.ActionResults;
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Exceptions;
using Microsoft.Extensions.Logging;
using System.Net;
public class HttpGlobalExceptionFilter : IExceptionFilter
{
private readonly IHostingEnvironment env;
private readonly ILogger<HttpGlobalExceptionFilter> logger;
public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger<HttpGlobalExceptionFilter> logger)
{
this.env = env;
this.logger = logger;
}
public void OnException(ExceptionContext context)
{
logger.LogError(new EventId(context.Exception.HResult),
context.Exception,
context.Exception.Message);
if (context.Exception.GetType() == typeof(LocationDomainException))
{
var json = new JsonErrorResponse
{
Messages = new[] { context.Exception.Message }
};
// Result asigned to a result object but in destiny the response is empty. This is a known bug of .net core 1.1
//It will be fixed in .net core 1.1.2. See https://github.com/aspnet/Mvc/issues/5594 for more information
context.Result = new BadRequestObjectResult(json);
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
}
else
{
var json = new JsonErrorResponse
{
Messages = new[] { "An error occur.Try it again." }
};
if (env.IsDevelopment())
{
json.DeveloperMessage = context.Exception;
}
// Result asigned to a result object but in destiny the response is empty. This is a known bug of .net core 1.1
// It will be fixed in .net core 1.1.2. See https://github.com/aspnet/Mvc/issues/5594 for more information
context.Result = new InternalServerErrorObjectResult(json);
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
}
context.ExceptionHandled = true;
}
private class JsonErrorResponse
{
public string[] Messages { get; set; }
public object DeveloperMessage { get; set; }
}
}
}

+ 0
- 79
src/Services/Location/Locations.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs View File

@ -1,79 +0,0 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Middlewares
{
class ByPassAuthMiddleware
{
private readonly RequestDelegate _next;
private string _currentUserId;
public ByPassAuthMiddleware(RequestDelegate next)
{
_next = next;
_currentUserId = null;
}
public async Task Invoke(HttpContext context)
{
var path = context.Request.Path;
if (path == "/noauth")
{
var userid = context.Request.Query["userid"];
if (!string.IsNullOrEmpty(userid))
{
_currentUserId = userid;
}
context.Response.StatusCode = 200;
context.Response.ContentType = "text/string";
await context.Response.WriteAsync($"User set to {_currentUserId}");
}
else if (path == "/noauth/reset")
{
_currentUserId = null;
context.Response.StatusCode = 200;
context.Response.ContentType = "text/string";
await context.Response.WriteAsync($"User set to none. Token required for protected endpoints.");
}
else
{
var currentUserId = _currentUserId;
var authHeader = context.Request.Headers["Authorization"];
if (authHeader != StringValues.Empty)
{
var header = authHeader.FirstOrDefault();
if (!string.IsNullOrEmpty(header) && header.StartsWith("Email ") && header.Length > "Email ".Length)
{
currentUserId = header.Substring("Email ".Length);
}
}
if (!string.IsNullOrEmpty(currentUserId))
{
var user = new ClaimsIdentity(new[] {
new Claim("emails", currentUserId),
new Claim("name", "Test user"),
new Claim("nonce", Guid.NewGuid().ToString()),
new Claim("ttp://schemas.microsoft.com/identity/claims/identityprovider", "ByPassAuthMiddleware"),
new Claim("nonce", Guid.NewGuid().ToString()),
new Claim("sub", "1234"),
new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname","User"),
new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname","Microsoft")}
, "ByPassAuth");
context.User = new ClaimsPrincipal(user);
}
await _next.Invoke(context);
}
}
}
}

+ 4
- 0
src/Services/Location/Locations.API/Locations.API.csproj View File

@ -28,6 +28,10 @@
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\Infrastructure\Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Infrastructure\Middlewares\" />
</ItemGroup> </ItemGroup>
</Project> </Project>

+ 4
- 3
src/Services/Location/Locations.API/Startup.cs View File

@ -11,9 +11,10 @@ using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ; using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus; using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
using Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Filters;
using Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Middlewares;
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure; using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure;
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Filters;
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Middlewares;
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Exceptions;
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Repositories; using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Repositories;
using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Services; using Microsoft.eShopOnContainers.Services.Locations.API.Infrastructure.Services;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
@ -44,7 +45,7 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
services.AddMvc(options => services.AddMvc(options =>
{ {
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
options.Filters.Add(typeof(HttpGlobalExceptionFilter<LocationDomainException>));
}).AddControllersAsServices(); }).AddControllersAsServices();
ConfigureAuthService(services); ConfigureAuthService(services);


+ 16
- 18
src/Services/Marketing/Marketing.API/Controllers/CampaignsController.cs View File

@ -1,24 +1,22 @@
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopOnContainers.Services.Common.API;
using Microsoft.eShopOnContainers.Services.Marketing.API.Dto;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Repositories;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Services;
using Microsoft.eShopOnContainers.Services.Marketing.API.Model;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Controllers namespace Microsoft.eShopOnContainers.Services.Marketing.API.Controllers
{ {
using System;
using System.Linq;
using System.Collections.Generic;
using Infrastructure.Repositories;
using AspNetCore.Mvc;
using Infrastructure;
using System.Threading.Tasks;
using Model;
using EntityFrameworkCore;
using Dto;
using AspNetCore.Authorization;
using Extensions.Options;
using Microsoft.eShopOnContainers.Services.Marketing.API.ViewModel;
using Microsoft.AspNetCore.Http;
using System.Net;
[Route("api/v1/[controller]")]
[Route("api/v1/[controller]")]
[Authorize] [Authorize]
public class CampaignsController : Controller public class CampaignsController : Controller
{ {


+ 0
- 14
src/Services/Marketing/Marketing.API/Infrastructure/ActionResult/InternalServerErrorObjectResult.cs View File

@ -1,14 +0,0 @@
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.ActionResults
{
using AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
public class InternalServerErrorObjectResult : ObjectResult
{
public InternalServerErrorObjectResult(object error)
: base(error)
{
StatusCode = StatusCodes.Status500InternalServerError;
}
}
}

+ 0
- 32
src/Services/Marketing/Marketing.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs View File

@ -1,32 +0,0 @@
using Microsoft.AspNetCore.Authorization;
using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Filters
{
public class AuthorizeCheckOperationFilter : IOperationFilter
{
public void Apply(Operation operation, OperationFilterContext context)
{
// Check for authorize attribute
var hasAuthorize = context.ApiDescription.ControllerAttributes().OfType<AuthorizeAttribute>().Any() ||
context.ApiDescription.ActionAttributes().OfType<AuthorizeAttribute>().Any();
if (hasAuthorize)
{
operation.Responses.Add("401", new Response { Description = "Unauthorized" });
operation.Responses.Add("403", new Response { Description = "Forbidden" });
operation.Security = new List<IDictionary<string, IEnumerable<string>>>
{
new Dictionary<string, IEnumerable<string>>
{
{ "oauth2", new [] { "marketingapi" } }
}
};
}
}
}
}

+ 0
- 67
src/Services/Marketing/Marketing.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs View File

@ -1,67 +0,0 @@
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Filters
{
using AspNetCore.Mvc;
using global::Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Exceptions;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.ActionResults;
using Microsoft.Extensions.Logging;
using System.Net;
public class HttpGlobalExceptionFilter : IExceptionFilter
{
private readonly IHostingEnvironment env;
private readonly ILogger<HttpGlobalExceptionFilter> logger;
public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger<HttpGlobalExceptionFilter> logger)
{
this.env = env;
this.logger = logger;
}
public void OnException(ExceptionContext context)
{
logger.LogError(new EventId(context.Exception.HResult),
context.Exception,
context.Exception.Message);
if (context.Exception.GetType() == typeof(MarketingDomainException))
{
var json = new JsonErrorResponse
{
Messages = new[] { context.Exception.Message }
};
// Result asigned to a result object but in destiny the response is empty. This is a known bug of .net core 1.1
//It will be fixed in .net core 1.1.2. See https://github.com/aspnet/Mvc/issues/5594 for more information
context.Result = new BadRequestObjectResult(json);
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
}
else
{
var json = new JsonErrorResponse
{
Messages = new[] { "An error occur.Try it again." }
};
if (env.IsDevelopment())
{
json.DeveloperMessage = context.Exception;
}
// Result asigned to a result object but in destiny the response is empty. This is a known bug of .net core 1.1
// It will be fixed in .net core 1.1.2. See https://github.com/aspnet/Mvc/issues/5594 for more information
context.Result = new InternalServerErrorObjectResult(json);
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
}
context.ExceptionHandled = true;
}
private class JsonErrorResponse
{
public string[] Messages { get; set; }
public object DeveloperMessage { get; set; }
}
}
}

+ 0
- 78
src/Services/Marketing/Marketing.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs View File

@ -1,78 +0,0 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
using System;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Middlewares
{
class ByPassAuthMiddleware
{
private readonly RequestDelegate _next;
private string _currentUserId;
public ByPassAuthMiddleware(RequestDelegate next)
{
_next = next;
_currentUserId = null;
}
public async Task Invoke(HttpContext context)
{
var path = context.Request.Path;
if (path == "/noauth")
{
var userid = context.Request.Query["userid"];
if (!string.IsNullOrEmpty(userid))
{
_currentUserId = userid;
}
context.Response.StatusCode = 200;
context.Response.ContentType = "text/string";
await context.Response.WriteAsync($"User set to {_currentUserId}");
}
else if (path == "/noauth/reset")
{
_currentUserId = null;
context.Response.StatusCode = 200;
context.Response.ContentType = "text/string";
await context.Response.WriteAsync($"User set to none. Token required for protected endpoints.");
}
else
{
var currentUserId = _currentUserId;
var authHeader = context.Request.Headers["Authorization"];
if (authHeader != StringValues.Empty)
{
var header = authHeader.FirstOrDefault();
if (!string.IsNullOrEmpty(header) && header.StartsWith("Email ") && header.Length > "Email ".Length)
{
currentUserId = header.Substring("Email ".Length);
}
}
if (!string.IsNullOrEmpty(currentUserId))
{
var user = new ClaimsIdentity(new[] {
new Claim("emails", currentUserId),
new Claim("name", "Test user"),
new Claim("nonce", Guid.NewGuid().ToString()),
new Claim("ttp://schemas.microsoft.com/identity/claims/identityprovider", "ByPassAuthMiddleware"),
new Claim("nonce", Guid.NewGuid().ToString()),
new Claim("sub", "1234"),
new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname","User"),
new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname","Microsoft")}
, "ByPassAuth");
context.User = new ClaimsPrincipal(user);
}
await _next.Invoke(context);
}
}
}
}

+ 3
- 0
src/Services/Marketing/Marketing.API/Marketing.API.csproj View File

@ -18,6 +18,7 @@
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content> </Content>
<Folder Include="Infrastructure\MarketingMigrations\" /> <Folder Include="Infrastructure\MarketingMigrations\" />
<Folder Include="ViewModel\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.0" />
@ -41,7 +42,9 @@
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.AzureStorage\Microsoft.Extensions.HealthChecks.AzureStorage.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.AzureStorage\Microsoft.Extensions.HealthChecks.AzureStorage.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusServiceBus\EventBusServiceBus.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusServiceBus\EventBusServiceBus.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\Infrastructure\Infrastructure.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\WebHostCustomization\WebHost.Customization\WebHost.Customization.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\WebHostCustomization\WebHost.Customization\WebHost.Customization.csproj" />
<ProjectReference Include="..\..\Common\Common.API\Common.API.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>


+ 37
- 36
src/Services/Marketing/Marketing.API/Startup.cs View File

@ -1,39 +1,40 @@
namespace Microsoft.eShopOnContainers.Services.Marketing.API
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.Azure.ServiceBus;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
using Microsoft.EntityFrameworkCore;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.ServiceFabric;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Filters;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Exceptions;
using RabbitMQ.Client;
using Swashbuckle.AspNetCore.Swagger;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure;
using Microsoft.Extensions.Logging;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Repositories;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Services;
using Microsoft.eShopOnContainers.Services.Marketing.API.IntegrationEvents.Handlers;
using Microsoft.eShopOnContainers.Services.Marketing.API.IntegrationEvents.Events;
using Microsoft.Extensions.HealthChecks;
using Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Middlewares;
namespace Microsoft.eShopOnContainers.Services.Marketing.API
{ {
using AspNetCore.Builder;
using AspNetCore.Hosting;
using AspNetCore.Http;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Azure.ServiceBus;
using BuildingBlocks.EventBus;
using BuildingBlocks.EventBus.Abstractions;
using BuildingBlocks.EventBusRabbitMQ;
using BuildingBlocks.EventBusServiceBus;
using EntityFrameworkCore;
using Extensions.Configuration;
using Extensions.DependencyInjection;
using Extensions.HealthChecks;
using Extensions.Logging;
using Infrastructure;
using Infrastructure.Filters;
using Infrastructure.Repositories;
using Infrastructure.Services;
using IntegrationEvents.Events;
using Marketing.API.IntegrationEvents.Handlers;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.ServiceFabric;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure.Middlewares;
using RabbitMQ.Client;
using Swashbuckle.AspNetCore.Swagger;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Reflection;
using System.Threading.Tasks;
public class Startup public class Startup
{ {
public Startup(IConfiguration configuration) public Startup(IConfiguration configuration)
@ -52,7 +53,7 @@
// Add framework services. // Add framework services.
services.AddMvc(options => services.AddMvc(options =>
{ {
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
options.Filters.Add(typeof(HttpGlobalExceptionFilter<MarketingDomainException>));
}).AddControllersAsServices(); //Injecting Controllers themselves thru DIFor further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services }).AddControllersAsServices(); //Injecting Controllers themselves thru DIFor further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services
services.Configure<MarketingSettings>(Configuration); services.Configure<MarketingSettings>(Configuration);


+ 0
- 23
src/Services/Marketing/Marketing.API/ViewModel/PaginatedItemsViewModel.cs View File

@ -1,23 +0,0 @@
namespace Microsoft.eShopOnContainers.Services.Marketing.API.ViewModel
{
using System.Collections.Generic;
public class PaginatedItemsViewModel<TEntity> where TEntity : class
{
public int PageIndex { get; private set; }
public int PageSize { get; private set; }
public long Count { get; private set; }
public IEnumerable<TEntity> Data { get; private set; }
public PaginatedItemsViewModel(int pageIndex, int pageSize, long count, IEnumerable<TEntity> data)
{
this.PageIndex = pageIndex;
this.PageSize = pageSize;
this.Count = count;
this.Data = data;
}
}
}

+ 0
- 14
src/Services/Ordering/Ordering.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs View File

@ -1,14 +0,0 @@
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.ActionResults
{
using AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
public class InternalServerErrorObjectResult : ObjectResult
{
public InternalServerErrorObjectResult(object error)
: base(error)
{
StatusCode = StatusCodes.Status500InternalServerError;
}
}
}

+ 0
- 32
src/Services/Ordering/Ordering.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs View File

@ -1,32 +0,0 @@
using Microsoft.AspNetCore.Authorization;
using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Ordering.API.Infrastructure.Filters
{
public class AuthorizeCheckOperationFilter : IOperationFilter
{
public void Apply(Operation operation, OperationFilterContext context)
{
// Check for authorize attribute
var hasAuthorize = context.ApiDescription.ControllerAttributes().OfType<AuthorizeAttribute>().Any() ||
context.ApiDescription.ActionAttributes().OfType<AuthorizeAttribute>().Any();
if (hasAuthorize)
{
operation.Responses.Add("401", new Response { Description = "Unauthorized" });
operation.Responses.Add("403", new Response { Description = "Forbidden" });
operation.Security = new List<IDictionary<string, IEnumerable<string>>>();
operation.Security.Add(new Dictionary<string, IEnumerable<string>>
{
{ "oauth2", new [] { "orderingapi" } }
});
}
}
}
}

+ 0
- 79
src/Services/Ordering/Ordering.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs View File

@ -1,79 +0,0 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace Ordering.API.Infrastructure.Middlewares
{
class ByPassAuthMiddleware
{
private readonly RequestDelegate _next;
private string _currentUserId;
public ByPassAuthMiddleware(RequestDelegate next)
{
_next = next;
_currentUserId = null;
}
public async Task Invoke(HttpContext context)
{
var path = context.Request.Path;
if (path == "/noauth")
{
var userid = context.Request.Query["userid"];
if (!string.IsNullOrEmpty(userid))
{
_currentUserId = userid;
}
context.Response.StatusCode = 200;
context.Response.ContentType = "text/string";
await context.Response.WriteAsync($"User set to {_currentUserId}");
}
else if (path == "/noauth/reset")
{
_currentUserId = null;
context.Response.StatusCode = 200;
context.Response.ContentType = "text/string";
await context.Response.WriteAsync($"User set to none. Token required for protected endpoints.");
}
else
{
var currentUserId = _currentUserId;
var authHeader = context.Request.Headers["Authorization"];
if (authHeader != StringValues.Empty)
{
var header = authHeader.FirstOrDefault();
if (!string.IsNullOrEmpty(header) && header.StartsWith("Email ") && header.Length > "Email ".Length)
{
currentUserId = header.Substring("Email ".Length);
}
}
if (!string.IsNullOrEmpty(currentUserId))
{
var user = new ClaimsIdentity(new[] {
new Claim("emails", currentUserId),
new Claim("name", "Test user"),
new Claim("nonce", Guid.NewGuid().ToString()),
new Claim("ttp://schemas.microsoft.com/identity/claims/identityprovider", "ByPassAuthMiddleware"),
new Claim("nonce", Guid.NewGuid().ToString()),
new Claim("sub", "1234"),
new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname","User"),
new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname","Microsoft")}
, "ByPassAuth");
context.User = new ClaimsPrincipal(user);
}
await _next.Invoke(context);
}
}
}
}

+ 20
- 19
src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs View File

@ -1,23 +1,24 @@
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure
using Microsoft.Extensions.Linq;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Ordering.Infrastructure;
using Polly;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure
{ {
using AspNetCore.Builder;
using global::Ordering.API.Extensions;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Ordering.Infrastructure;
using Polly;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
public class OrderingContextSeed public class OrderingContextSeed
{ {
public async Task SeedAsync(OrderingContext context, IHostingEnvironment env,IOptions<OrderingSettings> settings, ILogger<OrderingContextSeed> logger) public async Task SeedAsync(OrderingContext context, IHostingEnvironment env,IOptions<OrderingSettings> settings, ILogger<OrderingContextSeed> logger)


+ 6
- 0
src/Services/Ordering/Ordering.API/Ordering.API.csproj View File

@ -24,6 +24,8 @@
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.SqlServer\Microsoft.Extensions.HealthChecks.SqlServer.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.SqlServer\Microsoft.Extensions.HealthChecks.SqlServer.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\Infrastructure\Infrastructure.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\Linq\Microsoft.Extensions.Linq\Microsoft.Extensions.Linq.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\WebHostCustomization\WebHost.Customization\WebHost.Customization.csproj" /> <ProjectReference Include="..\..\..\BuildingBlocks\WebHostCustomization\WebHost.Customization\WebHost.Customization.csproj" />
<ProjectReference Include="..\Ordering.Domain\Ordering.Domain.csproj" /> <ProjectReference Include="..\Ordering.Domain\Ordering.Domain.csproj" />
<ProjectReference Include="..\Ordering.Infrastructure\Ordering.Infrastructure.csproj" /> <ProjectReference Include="..\Ordering.Infrastructure\Ordering.Infrastructure.csproj" />
@ -56,4 +58,8 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Infrastructure\Middlewares\" />
</ItemGroup>
</Project> </Project>

+ 40
- 39
src/Services/Ordering/Ordering.API/Startup.cs View File

@ -1,42 +1,43 @@
namespace Microsoft.eShopOnContainers.Services.Ordering.API
using Microsoft.AspNetCore.Http;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Ordering.API.Application.IntegrationEvents;
using Ordering.API.Application.IntegrationEvents.Events;
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules;
using Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Filters;
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Services;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.ServiceFabric;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Azure.ServiceBus;
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.HealthChecks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Ordering.Infrastructure;
using RabbitMQ.Client;
using Swashbuckle.AspNetCore.Swagger;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.IdentityModel.Tokens.Jwt;
using System.Reflection;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
using Ordering.Domain.Exceptions;
using Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Middlewares;
namespace Microsoft.eShopOnContainers.Services.Ordering.API
{ {
using AspNetCore.Http;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using global::Ordering.API.Application.IntegrationEvents;
using global::Ordering.API.Application.IntegrationEvents.Events;
using global::Ordering.API.Infrastructure.Filters;
using global::Ordering.API.Infrastructure.Middlewares;
using Infrastructure.AutofacModules;
using Infrastructure.Filters;
using Infrastructure.Services;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.ServiceFabric;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Azure.ServiceBus;
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.HealthChecks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Ordering.Infrastructure;
using RabbitMQ.Client;
using Swashbuckle.AspNetCore.Swagger;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.IdentityModel.Tokens.Jwt;
using System.Reflection;
public class Startup public class Startup
{ {
public Startup(IConfiguration configuration) public Startup(IConfiguration configuration)
@ -53,7 +54,7 @@
// Add framework services. // Add framework services.
services.AddMvc(options => services.AddMvc(options =>
{ {
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
options.Filters.Add(typeof(HttpGlobalExceptionFilter<OrderingDomainException>));
}).AddControllersAsServices(); //Injecting Controllers themselves thru DI }).AddControllersAsServices(); //Injecting Controllers themselves thru DI
//For further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services //For further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services


+ 6
- 0
src/Web/WebMVC/ByPassAuthMiddleware.cs View File

@ -0,0 +1,6 @@
namespace Microsoft.eShopOnContainers.WebMVC
{
internal class ByPassAuthMiddleware
{
}
}

+ 3
- 2
src/Web/WebMVC/Controllers/CampaignsController.cs View File

@ -8,7 +8,8 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Services; using Services;
using System; using System;
using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;
using ViewModels; using ViewModels;
using ViewModels.Pagination; using ViewModels.Pagination;
@ -43,7 +44,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
PaginationInfo = new PaginationInfo PaginationInfo = new PaginationInfo
{ {
ActualPage = page, ActualPage = page,
ItemsPerPage = campaignList.Data.Count,
ItemsPerPage = campaignList.Data.Count(),
TotalItems = campaignList.Count, TotalItems = campaignList.Count,
TotalPages = totalPages, TotalPages = totalPages,
Next = page == totalPages - 1 ? "is-disabled" : "", Next = page == totalPages - 1 ? "is-disabled" : "",


+ 2
- 1
src/Web/WebMVC/Controllers/CatalogController.cs View File

@ -5,6 +5,7 @@ using Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination;
using Microsoft.eShopOnContainers.WebMVC.Services; using Microsoft.eShopOnContainers.WebMVC.Services;
using Microsoft.eShopOnContainers.WebMVC.ViewModels.CatalogViewModels; using Microsoft.eShopOnContainers.WebMVC.ViewModels.CatalogViewModels;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using System.Linq;
namespace Microsoft.eShopOnContainers.WebMVC.Controllers namespace Microsoft.eShopOnContainers.WebMVC.Controllers
{ {
@ -29,7 +30,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
PaginationInfo = new PaginationInfo() PaginationInfo = new PaginationInfo()
{ {
ActualPage = page ?? 0, ActualPage = page ?? 0,
ItemsPerPage = catalog.Data.Count,
ItemsPerPage = catalog.Data.Count(),
TotalItems = catalog.Count, TotalItems = catalog.Count,
TotalPages = (int)Math.Ceiling(((decimal)catalog.Count / itemsPage)) TotalPages = (int)Math.Ceiling(((decimal)catalog.Count / itemsPage))
} }


+ 0
- 80
src/Web/WebMVC/Infrastructure/Middlewares/ByPassAuthMiddleware.cs View File

@ -1,80 +0,0 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace WebMVC.Infrastructure.Middlewares
{
class ByPassAuthMiddleware
{
private readonly RequestDelegate _next;
private string _currentUserId;
public ByPassAuthMiddleware(RequestDelegate next)
{
_next = next;
_currentUserId = null;
}
public async Task Invoke(HttpContext context)
{
var path = context.Request.Path;
if (path == "/noauth")
{
var userid = context.Request.Query["userid"];
if (!string.IsNullOrEmpty(userid))
{
_currentUserId = userid;
}
context.Response.StatusCode = 200;
context.Response.ContentType = "text/string";
await context.Response.WriteAsync($"User set to {_currentUserId}");
}
else if (path == "/noauth/reset")
{
_currentUserId = null;
context.Response.StatusCode = 200;
context.Response.ContentType = "text/string";
await context.Response.WriteAsync($"User set to none. Token required for protected endpoints.");
}
else
{
var currentUserId = _currentUserId;
var authHeader = context.Request.Headers["Authorization"];
if (authHeader != StringValues.Empty)
{
var header = authHeader.FirstOrDefault();
if (!string.IsNullOrEmpty(header) && header.StartsWith("Email ") && header.Length > "Email ".Length)
{
currentUserId = header.Substring("Email ".Length);
}
}
if (!string.IsNullOrEmpty(currentUserId))
{
var user = new ClaimsIdentity(new[] {
new Claim("emails", currentUserId),
new Claim("name", "Test user"),
new Claim("nonce", Guid.NewGuid().ToString()),
new Claim("ttp://schemas.microsoft.com/identity/claims/identityprovider", "ByPassAuthMiddleware"),
new Claim("nonce", Guid.NewGuid().ToString()),
new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname","User"),
new Claim("sub", "1234"),
new Claim("card_expiration", "12/20"),
new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname","Microsoft")}
, "ByPassAuth");
context.User = new ClaimsPrincipal(user);
}
await _next.Invoke(context);
}
}
}
}

+ 4
- 3
src/Web/WebMVC/Services/CampaignService.cs View File

@ -10,8 +10,9 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.eShopOnContainers.Services.Common.API;
public class CampaignService : ICampaignService
public class CampaignService : ICampaignService
{ {
private readonly IOptionsSnapshot<AppSettings> _settings; private readonly IOptionsSnapshot<AppSettings> _settings;
private readonly IHttpClient _apiClient; private readonly IHttpClient _apiClient;
@ -30,7 +31,7 @@
_httpContextAccesor = httpContextAccesor ?? throw new ArgumentNullException(nameof(httpContextAccesor)); _httpContextAccesor = httpContextAccesor ?? throw new ArgumentNullException(nameof(httpContextAccesor));
} }
public async Task<Campaign> GetCampaigns(int pageSize, int pageIndex)
public async Task<PaginatedItemsViewModel<CampaignItem>> GetCampaigns(int pageSize, int pageIndex)
{ {
var allCampaignItemsUri = API.Marketing.GetAllCampaigns(_remoteServiceBaseUrl, var allCampaignItemsUri = API.Marketing.GetAllCampaigns(_remoteServiceBaseUrl,
pageSize, pageIndex); pageSize, pageIndex);
@ -38,7 +39,7 @@
var authorizationToken = await GetUserTokenAsync(); var authorizationToken = await GetUserTokenAsync();
var dataString = await _apiClient.GetStringAsync(allCampaignItemsUri, authorizationToken); var dataString = await _apiClient.GetStringAsync(allCampaignItemsUri, authorizationToken);
var response = JsonConvert.DeserializeObject<Campaign>(dataString);
var response = JsonConvert.DeserializeObject<PaginatedItemsViewModel<CampaignItem>>(dataString);
return response; return response;
} }


+ 3
- 2
src/Web/WebMVC/Services/CatalogService.cs View File

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http;
using Microsoft.eShopOnContainers.Services.Common.API;
using Microsoft.eShopOnContainers.WebMVC.ViewModels; using Microsoft.eShopOnContainers.WebMVC.ViewModels;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
@ -28,13 +29,13 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services
_remoteServiceBaseUrl = $"{_settings.Value.CatalogUrl}/api/v1/catalog/"; _remoteServiceBaseUrl = $"{_settings.Value.CatalogUrl}/api/v1/catalog/";
} }
public async Task<Catalog> GetCatalogItems(int page, int take, int? brand, int? type)
public async Task<PaginatedItemsViewModel<CatalogItem>> GetCatalogItems(int page, int take, int? brand, int? type)
{ {
var allcatalogItemsUri = API.Catalog.GetAllCatalogItems(_remoteServiceBaseUrl, page, take, brand, type); var allcatalogItemsUri = API.Catalog.GetAllCatalogItems(_remoteServiceBaseUrl, page, take, brand, type);
var dataString = await _apiClient.GetStringAsync(allcatalogItemsUri); var dataString = await _apiClient.GetStringAsync(allcatalogItemsUri);
var response = JsonConvert.DeserializeObject<Catalog>(dataString);
var response = JsonConvert.DeserializeObject<PaginatedItemsViewModel<CatalogItem>>(dataString);
return response; return response;
} }


+ 3
- 2
src/Web/WebMVC/Services/ICampaignService.cs View File

@ -1,12 +1,13 @@
namespace Microsoft.eShopOnContainers.WebMVC.Services namespace Microsoft.eShopOnContainers.WebMVC.Services
{ {
using System.Collections.Generic;
using Microsoft.eShopOnContainers.Services.Common.API;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using ViewModels; using ViewModels;
public interface ICampaignService public interface ICampaignService
{ {
Task<Campaign> GetCampaigns(int pageSize, int pageIndex);
Task<PaginatedItemsViewModel<CampaignItem>> GetCampaigns(int pageSize, int pageIndex);
Task<CampaignItem> GetCampaignById(int id); Task<CampaignItem> GetCampaignById(int id);
} }

+ 2
- 1
src/Web/WebMVC/Services/ICatalogService.cs View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.eShopOnContainers.Services.Common.API;
using Microsoft.eShopOnContainers.WebMVC.ViewModels; using Microsoft.eShopOnContainers.WebMVC.ViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -9,7 +10,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services
{ {
public interface ICatalogService public interface ICatalogService
{ {
Task<Catalog> GetCatalogItems(int page, int take, int? brand, int? type);
Task<PaginatedItemsViewModel<CatalogItem>> GetCatalogItems(int page, int take, int? brand, int? type);
Task<IEnumerable<SelectListItem>> GetBrands(); Task<IEnumerable<SelectListItem>> GetBrands();
Task<IEnumerable<SelectListItem>> GetTypes(); Task<IEnumerable<SelectListItem>> GetTypes();
} }


+ 0
- 1
src/Web/WebMVC/Startup.cs View File

@ -18,7 +18,6 @@ using StackExchange.Redis;
using System; using System;
using System.IdentityModel.Tokens.Jwt; using System.IdentityModel.Tokens.Jwt;
using WebMVC.Infrastructure; using WebMVC.Infrastructure;
using WebMVC.Infrastructure.Middlewares;
using WebMVC.Services; using WebMVC.Services;
namespace Microsoft.eShopOnContainers.WebMVC namespace Microsoft.eShopOnContainers.WebMVC


+ 0
- 12
src/Web/WebMVC/ViewModels/Campaign.cs View File

@ -1,12 +0,0 @@
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
{
using System.Collections.Generic;
public class Campaign
{
public int PageIndex { get; set; }
public int PageSize { get; set; }
public int Count { get; set; }
public List<CampaignItem> Data { get; set; }
}
}

+ 1
- 1
src/Web/WebMVC/ViewModels/Pagination/PaginationInfo.cs View File

@ -7,7 +7,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination
{ {
public class PaginationInfo public class PaginationInfo
{ {
public int TotalItems { get; set; }
public long TotalItems { get; set; }
public int ItemsPerPage { get; set; } public int ItemsPerPage { get; set; }
public int ActualPage { get; set; } public int ActualPage { get; set; }
public int TotalPages { get; set; } public int TotalPages { get; set; }


+ 5
- 0
src/Web/WebMVC/WebMVC.csproj View File

@ -42,10 +42,15 @@
<ProjectReference Include="..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" /> <ProjectReference Include="..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
<ProjectReference Include="..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" /> <ProjectReference Include="..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
<ProjectReference Include="..\..\BuildingBlocks\Resilience\Resilience.Http\Resilience.Http.csproj" /> <ProjectReference Include="..\..\BuildingBlocks\Resilience\Resilience.Http\Resilience.Http.csproj" />
<ProjectReference Include="..\..\Services\Common\Common.API\Common.API.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="ViewModels\CampaignItem.cs" /> <None Include="ViewModels\CampaignItem.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Infrastructure\Middlewares\" />
</ItemGroup>
</Project> </Project>

+ 1
- 0
src/Web/WebSPA/WebSPA.csproj View File

@ -8,6 +8,7 @@
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<GeneratedItemPatterns>wwwroot/dist/**</GeneratedItemPatterns> <GeneratedItemPatterns>wwwroot/dist/**</GeneratedItemPatterns>
<DefaultItemExcludes>$(DefaultItemExcludes);$(GeneratedItemPatterns)</DefaultItemExcludes> <DefaultItemExcludes>$(DefaultItemExcludes);$(GeneratedItemPatterns)</DefaultItemExcludes>
<TypeScriptToolsVersion>2.5</TypeScriptToolsVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>


+ 1
- 1
test/Services/FunctionalTests/Services/IntegrationEventsScenarios.cs View File

@ -2,7 +2,6 @@
using FunctionalTests.Services.Catalog; using FunctionalTests.Services.Catalog;
using Microsoft.eShopOnContainers.Services.Basket.API.Model; using Microsoft.eShopOnContainers.Services.Basket.API.Model;
using Microsoft.eShopOnContainers.Services.Catalog.API.Model; using Microsoft.eShopOnContainers.Services.Catalog.API.Model;
using Microsoft.eShopOnContainers.Services.Catalog.API.ViewModel;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Linq; using System.Linq;
@ -12,6 +11,7 @@ using System.Threading.Tasks;
using Xunit; using Xunit;
using System.Net.Http; using System.Net.Http;
using System.Threading; using System.Threading;
using Microsoft.eShopOnContainers.Services.Common.API;
namespace FunctionalTests.Services namespace FunctionalTests.Services
{ {


+ 0
- 1
test/Services/FunctionalTests/Services/Marketing/MarketingScenarios.cs View File

@ -11,7 +11,6 @@
using Xunit; using Xunit;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.eShopOnContainers.Services.Marketing.API.Dto; using Microsoft.eShopOnContainers.Services.Marketing.API.Dto;
using Microsoft.eShopOnContainers.Services.Catalog.API.ViewModel;
public class MarketingScenarios : MarketingScenariosBase public class MarketingScenarios : MarketingScenariosBase
{ {


+ 24
- 29
test/Services/UnitTest/Catalog/Application/CatalogControllerTest.cs View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.eShopOnContainers.Services.Common.API;
using Microsoft.eShopOnContainers.WebMVC.Controllers; using Microsoft.eShopOnContainers.WebMVC.Controllers;
using Microsoft.eShopOnContainers.WebMVC.Services; using Microsoft.eShopOnContainers.WebMVC.Services;
using Microsoft.eShopOnContainers.WebMVC.ViewModels; using Microsoft.eShopOnContainers.WebMVC.ViewModels;
@ -7,7 +8,7 @@ using Moq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xunit; using Xunit;
using CatalogModel = Microsoft.eShopOnContainers.WebMVC.ViewModels.Catalog;
using CatalogModel = Microsoft.eShopOnContainers.Services.Common.API.PaginatedItemsViewModel<Microsoft.eShopOnContainers.WebMVC.ViewModels.CatalogItem>;
namespace UnitTest.Catalog.Application namespace UnitTest.Catalog.Application
{ {
@ -56,35 +57,29 @@ namespace UnitTest.Catalog.Application
Assert.Empty(model.PaginationInfo.Previous); Assert.Empty(model.PaginationInfo.Previous);
} }
private CatalogModel GetFakeCatalog()
private PaginatedItemsViewModel<CatalogItem> GetFakeCatalog()
{ {
return new CatalogModel()
{
PageSize = 10,
Count = 50,
PageIndex = 2,
Data = new List<CatalogItem>()
{
new CatalogItem()
{
Id = "1",
Name = "fakeItemA",
CatalogTypeId = 1
},
new CatalogItem()
{
Id = "2",
Name = "fakeItemB",
CatalogTypeId = 1
},
new CatalogItem()
{
Id = "3",
Name = "fakeItemC",
CatalogTypeId = 1
}
}
};
return new PaginatedItemsViewModel<CatalogItem>(2, 10, 50, new List<CatalogItem>
{
new CatalogItem()
{
Id = "1",
Name = "fakeItemA",
CatalogTypeId = 1
},
new CatalogItem()
{
Id = "2",
Name = "fakeItemB",
CatalogTypeId = 1
},
new CatalogItem()
{
Id = "3",
Name = "fakeItemC",
CatalogTypeId = 1
}
});
} }
} }
} }

Loading…
Cancel
Save