diff --git a/eShopOnContainers.sln b/eShopOnContainers.sln index ebee1f162..61191d2ae 100644 --- a/eShopOnContainers.sln +++ b/eShopOnContainers.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27130.2024 +VisualStudioVersion = 15.0.27130.2027 MinimumVisualStudioVersion = 10.0.40219.1 Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{FEA0C318-FFED-4D39-8781-265718CA43DD}" EndProject @@ -123,6 +123,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eShopOnContainers.TestRunne EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ordering.BackgroundTasks", "src\Services\Ordering\Ordering.BackgroundTasks\Ordering.BackgroundTasks.csproj", "{16CDE5D2-2DDE-4AF2-B902-AD9CC42DE480}" 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 GlobalSection(SolutionConfigurationPlatforms) = preSolution 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|x86.ActiveCfg = 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 GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1868,6 +2024,12 @@ Global {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3} = {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} + {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 GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9} diff --git a/src/Services/Basket/Basket.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs b/src/BuildingBlocks/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs similarity index 79% rename from src/Services/Basket/Basket.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs rename to src/BuildingBlocks/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs index a0b988156..699588d17 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs +++ b/src/BuildingBlocks/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs @@ -1,8 +1,9 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -namespace Basket.API.Infrastructure.ActionResults +namespace Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.ActionResults { + public class InternalServerErrorObjectResult : ObjectResult { public InternalServerErrorObjectResult(object error) @@ -11,4 +12,4 @@ namespace Basket.API.Infrastructure.ActionResults StatusCode = StatusCodes.Status500InternalServerError; } } -} +} \ No newline at end of file diff --git a/src/Services/Basket/Basket.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs b/src/BuildingBlocks/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs similarity index 93% rename from src/Services/Basket/Basket.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs rename to src/BuildingBlocks/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs index 7caa9740d..f97d8c1a9 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs +++ b/src/BuildingBlocks/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs @@ -4,7 +4,7 @@ using Swashbuckle.AspNetCore.SwaggerGen; using System.Collections.Generic; using System.Linq; -namespace Basket.API.Infrastructure.Filters +namespace Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Filters { public class AuthorizeCheckOperationFilter : IOperationFilter { diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs b/src/BuildingBlocks/Infrastructure/Filters/HttpGlobalExceptionFilter.cs similarity index 69% rename from src/Services/Ordering/Ordering.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs rename to src/BuildingBlocks/Infrastructure/Filters/HttpGlobalExceptionFilter.cs index 69faf8e42..8de49c68a 100644 --- a/src/Services/Ordering/Ordering.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs +++ b/src/BuildingBlocks/Infrastructure/Filters/HttpGlobalExceptionFilter.cs @@ -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 : IExceptionFilter { private readonly IHostingEnvironment env; - private readonly ILogger logger; + private readonly ILogger> logger; - public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger logger) + public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger> logger) { this.env = env; this.logger = logger; @@ -25,7 +25,7 @@ context.Exception, context.Exception.Message); - if (context.Exception.GetType() == typeof(OrderingDomainException)) + if (context.Exception.GetType() == typeof(T)) { var json = new JsonErrorResponse { @@ -57,11 +57,5 @@ context.ExceptionHandled = true; } - private class JsonErrorResponse - { - public string[] Messages { get; set; } - - public object DeveloperMessage { get; set; } - } } -} +} \ No newline at end of file diff --git a/src/Services/Basket/Basket.API/Infrastructure/Filters/JsonErrorResponse.cs b/src/BuildingBlocks/Infrastructure/Filters/JsonErrorResponse.cs similarity index 51% rename from src/Services/Basket/Basket.API/Infrastructure/Filters/JsonErrorResponse.cs rename to src/BuildingBlocks/Infrastructure/Filters/JsonErrorResponse.cs index bcadc7358..6a8108c1b 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/Filters/JsonErrorResponse.cs +++ b/src/BuildingBlocks/Infrastructure/Filters/JsonErrorResponse.cs @@ -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; } diff --git a/src/Services/Basket/Basket.API/Infrastructure/Filters/ValidateModelStateFilter.cs b/src/BuildingBlocks/Infrastructure/Filters/ValidateModelStateFilter.cs similarity index 90% rename from src/Services/Basket/Basket.API/Infrastructure/Filters/ValidateModelStateFilter.cs rename to src/BuildingBlocks/Infrastructure/Filters/ValidateModelStateFilter.cs index 3e4c3e072..d3f8495d5 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/Filters/ValidateModelStateFilter.cs +++ b/src/BuildingBlocks/Infrastructure/Filters/ValidateModelStateFilter.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc.Filters; using System.Linq; -namespace Basket.API.Infrastructure.Filters +namespace Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Filters { public class ValidateModelStateFilter : ActionFilterAttribute { diff --git a/src/BuildingBlocks/Infrastructure/Infrastructure.csproj b/src/BuildingBlocks/Infrastructure/Infrastructure.csproj new file mode 100644 index 000000000..66b7ecf0f --- /dev/null +++ b/src/BuildingBlocks/Infrastructure/Infrastructure.csproj @@ -0,0 +1,25 @@ + + + + netcoreapp2.0 + Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure + + + + + + + + + + C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.hosting.abstractions\2.0.1\lib\netstandard2.0\Microsoft.AspNetCore.Hosting.Abstractions.dll + + + C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.abstractions\2.0.2\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Abstractions.dll + + + C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.logging.abstractions\2.0.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + + + diff --git a/src/Services/Basket/Basket.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs b/src/BuildingBlocks/Infrastructure/Middlewares/ByPassAuthMiddleware.cs similarity index 95% rename from src/Services/Basket/Basket.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs rename to src/BuildingBlocks/Infrastructure/Middlewares/ByPassAuthMiddleware.cs index dfe690f6f..deb547e14 100644 --- a/src/Services/Basket/Basket.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs +++ b/src/BuildingBlocks/Infrastructure/Middlewares/ByPassAuthMiddleware.cs @@ -1,14 +1,13 @@ 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 Basket.API.Infrastructure.Middlewares +namespace Microsoft.eShopOnContainers.BuildingBlocks.Infrastructure.Middlewares { - class ByPassAuthMiddleware + public class ByPassAuthMiddleware { private readonly RequestDelegate _next; private string _currentUserId; @@ -64,8 +63,8 @@ namespace Basket.API.Infrastructure.Middlewares 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("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"); diff --git a/src/Services/Ordering/Ordering.API/Extensions/LinqSelectExtensions.cs b/src/BuildingBlocks/Linq/Microsoft.Extensions.Linq/LinqSelectExtensions.cs similarity index 98% rename from src/Services/Ordering/Ordering.API/Extensions/LinqSelectExtensions.cs rename to src/BuildingBlocks/Linq/Microsoft.Extensions.Linq/LinqSelectExtensions.cs index 4efe08c07..4ca4759ec 100644 --- a/src/Services/Ordering/Ordering.API/Extensions/LinqSelectExtensions.cs +++ b/src/BuildingBlocks/Linq/Microsoft.Extensions.Linq/LinqSelectExtensions.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; -namespace Ordering.API.Extensions +namespace Microsoft.Extensions.Linq { public static class LinqSelectExtensions { diff --git a/src/BuildingBlocks/Linq/Microsoft.Extensions.Linq/Microsoft.Extensions.Linq.csproj b/src/BuildingBlocks/Linq/Microsoft.Extensions.Linq/Microsoft.Extensions.Linq.csproj new file mode 100644 index 000000000..9f5c4f4ab --- /dev/null +++ b/src/BuildingBlocks/Linq/Microsoft.Extensions.Linq/Microsoft.Extensions.Linq.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Resources/Resource.Designer.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Resources/Resource.Designer.cs index 074729b61..b3aa8d16c 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Resources/Resource.Designer.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Resources/Resource.Designer.cs @@ -2274,9 +2274,27 @@ namespace eShopOnContainers.Droid // aapt resource value: 0x7f020054 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 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 public const int background = 2130837590; diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/Resources/Resource.Designer.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/Resources/Resource.Designer.cs index cf88d1538..694a01864 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/Resources/Resource.Designer.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/Resources/Resource.Designer.cs @@ -2268,9 +2268,27 @@ namespace eShopOnContainers.TestRunner.Droid // aapt resource value: 0x7f020053 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 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 public const int design_bottom_navigation_item_background = 2130837589; diff --git a/src/Services/Basket/Basket.API/Basket.API.csproj b/src/Services/Basket/Basket.API/Basket.API.csproj index 0866e1161..82df1ba07 100644 --- a/src/Services/Basket/Basket.API/Basket.API.csproj +++ b/src/Services/Basket/Basket.API/Basket.API.csproj @@ -28,6 +28,12 @@ + + + + + + diff --git a/src/Services/Basket/Basket.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs b/src/Services/Basket/Basket.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs deleted file mode 100644 index dab725915..000000000 --- a/src/Services/Basket/Basket.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs +++ /dev/null @@ -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 logger; - - public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger 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; - } - } -} diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index 86b57c0cd..7ae4baade 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -1,6 +1,6 @@ using Autofac; using Autofac.Extensions.DependencyInjection; -using Basket.API.Infrastructure.Filters; +using Basket.API.Infrastructure.Exceptions; using Basket.API.Infrastructure.Middlewares; using Basket.API.IntegrationEvents.EventHandling; using Basket.API.IntegrationEvents.Events; @@ -15,6 +15,8 @@ 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.Infrastructure.Middlewares; using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.EventHandling; using Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Events; using Microsoft.eShopOnContainers.Services.Basket.API.Model; @@ -52,7 +54,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API // Add framework services. services.AddMvc(options => { - options.Filters.Add(typeof(HttpGlobalExceptionFilter)); + options.Filters.Add(typeof(HttpGlobalExceptionFilter)); options.Filters.Add(typeof(ValidateModelStateFilter)); }).AddControllersAsServices(); diff --git a/src/Services/Catalog/Catalog.API/Catalog.API.csproj b/src/Services/Catalog/Catalog.API/Catalog.API.csproj index 749c00efd..69043f349 100644 --- a/src/Services/Catalog/Catalog.API/Catalog.API.csproj +++ b/src/Services/Catalog/Catalog.API/Catalog.API.csproj @@ -57,7 +57,10 @@ + + + @@ -69,4 +72,10 @@ + + + + + + diff --git a/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs b/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs index 1b53171d0..2d8fdb346 100644 --- a/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs +++ b/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs @@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events; 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 System; using System.Collections.Generic; diff --git a/src/Services/Catalog/Catalog.API/Extensions/LinqSelectExtensions.cs b/src/Services/Catalog/Catalog.API/Extensions/LinqSelectExtensions.cs deleted file mode 100644 index 1e5fbf789..000000000 --- a/src/Services/Catalog/Catalog.API/Extensions/LinqSelectExtensions.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Catalog.API.Extensions -{ - public static class LinqSelectExtensions - { - public static IEnumerable> SelectTry(this IEnumerable enumerable, Func selector) - { - foreach (TSource element in enumerable) - { - SelectTryResult returnedValue; - try - { - returnedValue = new SelectTryResult(element, selector(element), null); - } - catch (Exception ex) - { - returnedValue = new SelectTryResult(element, default(TResult), ex); - } - yield return returnedValue; - } - } - - public static IEnumerable OnCaughtException(this IEnumerable> enumerable, Func exceptionHandler) - { - return enumerable.Select(x => x.CaughtException == null ? x.Result : exceptionHandler(x.CaughtException)); - } - - public static IEnumerable OnCaughtException(this IEnumerable> enumerable, Func exceptionHandler) - { - return enumerable.Select(x => x.CaughtException == null ? x.Result : exceptionHandler(x.Source, x.CaughtException)); - } - - public class SelectTryResult - { - 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; } - } - } -} diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs b/src/Services/Catalog/Catalog.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs deleted file mode 100644 index a6138b476..000000000 --- a/src/Services/Catalog/Catalog.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs +++ /dev/null @@ -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; - } - } -} diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs index 42ac7b740..6dccc144a 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs @@ -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 async Task SeedAsync(CatalogContext context,IHostingEnvironment env,IOptions settings,ILogger logger) diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs b/src/Services/Catalog/Catalog.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs deleted file mode 100644 index e618d3eed..000000000 --- a/src/Services/Catalog/Catalog.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs +++ /dev/null @@ -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 logger; - - public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger 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; } - } - } -} diff --git a/src/Services/Catalog/Catalog.API/Startup.cs b/src/Services/Catalog/Catalog.API/Startup.cs index 5eec48959..0b994eafd 100644 --- a/src/Services/Catalog/Catalog.API/Startup.cs +++ b/src/Services/Catalog/Catalog.API/Startup.cs @@ -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 Startup(IConfiguration configuration) @@ -64,7 +65,7 @@ services.AddMvc(options => { - options.Filters.Add(typeof(HttpGlobalExceptionFilter)); + options.Filters.Add(typeof(HttpGlobalExceptionFilter)); }).AddControllersAsServices(); services.AddDbContext(options => diff --git a/src/Services/Catalog/Catalog.API/ViewModel/PaginatedItemsViewModel.cs b/src/Services/Catalog/Catalog.API/ViewModel/PaginatedItemsViewModel.cs deleted file mode 100644 index 844f38e2b..000000000 --- a/src/Services/Catalog/Catalog.API/ViewModel/PaginatedItemsViewModel.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Catalog.API.ViewModel -{ - using System.Collections.Generic; - - - public class PaginatedItemsViewModel where TEntity : class - { - public int PageIndex { get; private set; } - - public int PageSize { get; private set; } - - public long Count { get; private set; } - - public IEnumerable Data { get; private set; } - - public PaginatedItemsViewModel(int pageIndex, int pageSize, long count, IEnumerable data) - { - this.PageIndex = pageIndex; - this.PageSize = pageSize; - this.Count = count; - this.Data = data; - } - } -} diff --git a/src/Services/Common/Common.API/Common.API.csproj b/src/Services/Common/Common.API/Common.API.csproj new file mode 100644 index 000000000..910d4d2f2 --- /dev/null +++ b/src/Services/Common/Common.API/Common.API.csproj @@ -0,0 +1,9 @@ + + + + netstandard2.0 + Common.API + Microsoft.eShopOnContainers.Services.Common.API + + + diff --git a/src/Services/Common/Common.API/PaginatedItemsViewModel.cs b/src/Services/Common/Common.API/PaginatedItemsViewModel.cs new file mode 100644 index 000000000..c24dd5e7c --- /dev/null +++ b/src/Services/Common/Common.API/PaginatedItemsViewModel.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.eShopOnContainers.Services.Common.API +{ + public class PaginatedItemsViewModel where TEntity : class + { + public int PageIndex { get; private set; } + + public int PageSize { get; private set; } + + public long Count { get; private set; } + + public IEnumerable Data { get; private set; } + + public PaginatedItemsViewModel(int pageIndex, int pageSize, long count, IEnumerable data) + { + this.PageIndex = pageIndex; + this.PageSize = pageSize; + this.Count = count; + this.Data = data; + } + } +} diff --git a/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs b/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs index 3dbf28171..3c4534a94 100644 --- a/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs +++ b/src/Services/Identity/Identity.API/Data/ApplicationDbContextSeed.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Identity; -using Microsoft.eShopOnContainers.Services.Identity.API.Extensions; +using Microsoft.Extensions.Linq; using Microsoft.eShopOnContainers.Services.Identity.API.Models; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; diff --git a/src/Services/Identity/Identity.API/Extensions/LinqSelectExtensions.cs b/src/Services/Identity/Identity.API/Extensions/LinqSelectExtensions.cs deleted file mode 100644 index 1061881af..000000000 --- a/src/Services/Identity/Identity.API/Extensions/LinqSelectExtensions.cs +++ /dev/null @@ -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> SelectTry(this IEnumerable enumerable, Func selector) - { - foreach (TSource element in enumerable) - { - SelectTryResult returnedValue; - try - { - returnedValue = new SelectTryResult(element, selector(element), null); - } - catch (Exception ex) - { - returnedValue = new SelectTryResult(element, default(TResult), ex); - } - yield return returnedValue; - } - } - - public static IEnumerable OnCaughtException(this IEnumerable> enumerable, Func exceptionHandler) - { - return enumerable.Select(x => x.CaughtException == null ? x.Result : exceptionHandler(x.CaughtException)); - } - - public static IEnumerable OnCaughtException(this IEnumerable> enumerable, Func exceptionHandler) - { - return enumerable.Select(x => x.CaughtException == null ? x.Result : exceptionHandler(x.Source, x.CaughtException)); - } - - public class SelectTryResult - { - 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; } - } - } -} diff --git a/src/Services/Identity/Identity.API/Identity.API.csproj b/src/Services/Identity/Identity.API/Identity.API.csproj index c3b7cc5d3..02d9c7742 100644 --- a/src/Services/Identity/Identity.API/Identity.API.csproj +++ b/src/Services/Identity/Identity.API/Identity.API.csproj @@ -46,6 +46,7 @@ + @@ -55,8 +56,4 @@ - - - - diff --git a/src/Services/Location/Locations.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs b/src/Services/Location/Locations.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs deleted file mode 100644 index 772129da9..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs +++ /dev/null @@ -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; - } - } -} diff --git a/src/Services/Location/Locations.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs b/src/Services/Location/Locations.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs deleted file mode 100644 index 8eccc83cf..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs +++ /dev/null @@ -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().Any() || - context.ApiDescription.ActionAttributes().OfType().Any(); - - if (hasAuthorize) - { - operation.Responses.Add("401", new Response { Description = "Unauthorized" }); - operation.Responses.Add("403", new Response { Description = "Forbidden" }); - - operation.Security = new List>>(); - operation.Security.Add(new Dictionary> - { - { "oauth2", new [] { "locationsapi" } } - }); - } - } - } -} diff --git a/src/Services/Location/Locations.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs b/src/Services/Location/Locations.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs deleted file mode 100644 index 30b9df1fa..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs +++ /dev/null @@ -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 logger; - - public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger 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; } - } - } -} diff --git a/src/Services/Location/Locations.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs b/src/Services/Location/Locations.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs deleted file mode 100644 index ae21d10cc..000000000 --- a/src/Services/Location/Locations.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs +++ /dev/null @@ -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); - } - } - } -} diff --git a/src/Services/Location/Locations.API/Locations.API.csproj b/src/Services/Location/Locations.API/Locations.API.csproj index 9ea93b9e4..cb9b0650a 100644 --- a/src/Services/Location/Locations.API/Locations.API.csproj +++ b/src/Services/Location/Locations.API/Locations.API.csproj @@ -28,6 +28,10 @@ + + + + diff --git a/src/Services/Location/Locations.API/Startup.cs b/src/Services/Location/Locations.API/Startup.cs index e69180e61..b62ef0d93 100644 --- a/src/Services/Location/Locations.API/Startup.cs +++ b/src/Services/Location/Locations.API/Startup.cs @@ -11,9 +11,10 @@ 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.Infrastructure.Middlewares; 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.Services; using Microsoft.Extensions.Configuration; @@ -44,7 +45,7 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API services.AddMvc(options => { - options.Filters.Add(typeof(HttpGlobalExceptionFilter)); + options.Filters.Add(typeof(HttpGlobalExceptionFilter)); }).AddControllersAsServices(); ConfigureAuthService(services); diff --git a/src/Services/Marketing/Marketing.API/Controllers/CampaignsController.cs b/src/Services/Marketing/Marketing.API/Controllers/CampaignsController.cs index 313d4d77b..bea49d5c7 100644 --- a/src/Services/Marketing/Marketing.API/Controllers/CampaignsController.cs +++ b/src/Services/Marketing/Marketing.API/Controllers/CampaignsController.cs @@ -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 { - 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] public class CampaignsController : Controller { diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/ActionResult/InternalServerErrorObjectResult.cs b/src/Services/Marketing/Marketing.API/Infrastructure/ActionResult/InternalServerErrorObjectResult.cs deleted file mode 100644 index 5975d92af..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/ActionResult/InternalServerErrorObjectResult.cs +++ /dev/null @@ -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; - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs b/src/Services/Marketing/Marketing.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs deleted file mode 100644 index 2b4e15188..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs +++ /dev/null @@ -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().Any() || - context.ApiDescription.ActionAttributes().OfType().Any(); - - if (hasAuthorize) - { - operation.Responses.Add("401", new Response { Description = "Unauthorized" }); - operation.Responses.Add("403", new Response { Description = "Forbidden" }); - - operation.Security = new List>> - { - new Dictionary> - { - { "oauth2", new [] { "marketingapi" } } - } - }; - } - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs b/src/Services/Marketing/Marketing.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs deleted file mode 100644 index 14e79775d..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs +++ /dev/null @@ -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 logger; - - public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger 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; } - } - } -} \ No newline at end of file diff --git a/src/Services/Marketing/Marketing.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs b/src/Services/Marketing/Marketing.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs deleted file mode 100644 index d89e15a7c..000000000 --- a/src/Services/Marketing/Marketing.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs +++ /dev/null @@ -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); - } - } - } -} diff --git a/src/Services/Marketing/Marketing.API/Marketing.API.csproj b/src/Services/Marketing/Marketing.API/Marketing.API.csproj index d566408ec..ee6f4df65 100644 --- a/src/Services/Marketing/Marketing.API/Marketing.API.csproj +++ b/src/Services/Marketing/Marketing.API/Marketing.API.csproj @@ -18,6 +18,7 @@ PreserveNewest + @@ -41,7 +42,9 @@ + + diff --git a/src/Services/Marketing/Marketing.API/Startup.cs b/src/Services/Marketing/Marketing.API/Startup.cs index f2dcd1578..1168637ea 100644 --- a/src/Services/Marketing/Marketing.API/Startup.cs +++ b/src/Services/Marketing/Marketing.API/Startup.cs @@ -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 Startup(IConfiguration configuration) @@ -52,7 +53,7 @@ // Add framework services. services.AddMvc(options => { - options.Filters.Add(typeof(HttpGlobalExceptionFilter)); + options.Filters.Add(typeof(HttpGlobalExceptionFilter)); }).AddControllersAsServices(); //Injecting Controllers themselves thru DIFor further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services services.Configure(Configuration); diff --git a/src/Services/Marketing/Marketing.API/ViewModel/PaginatedItemsViewModel.cs b/src/Services/Marketing/Marketing.API/ViewModel/PaginatedItemsViewModel.cs deleted file mode 100644 index 73225b4cf..000000000 --- a/src/Services/Marketing/Marketing.API/ViewModel/PaginatedItemsViewModel.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Microsoft.eShopOnContainers.Services.Marketing.API.ViewModel -{ - using System.Collections.Generic; - - public class PaginatedItemsViewModel where TEntity : class - { - public int PageIndex { get; private set; } - - public int PageSize { get; private set; } - - public long Count { get; private set; } - - public IEnumerable Data { get; private set; } - - public PaginatedItemsViewModel(int pageIndex, int pageSize, long count, IEnumerable data) - { - this.PageIndex = pageIndex; - this.PageSize = pageSize; - this.Count = count; - this.Data = data; - } - } -} \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs b/src/Services/Ordering/Ordering.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs deleted file mode 100644 index 55cb33c99..000000000 --- a/src/Services/Ordering/Ordering.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs +++ /dev/null @@ -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; - } - } -} diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs b/src/Services/Ordering/Ordering.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs deleted file mode 100644 index 3b569e0ba..000000000 --- a/src/Services/Ordering/Ordering.API/Infrastructure/Filters/AuthorizeCheckOperationFilter.cs +++ /dev/null @@ -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().Any() || - context.ApiDescription.ActionAttributes().OfType().Any(); - - if (hasAuthorize) - { - operation.Responses.Add("401", new Response { Description = "Unauthorized" }); - operation.Responses.Add("403", new Response { Description = "Forbidden" }); - - operation.Security = new List>>(); - operation.Security.Add(new Dictionary> - { - { "oauth2", new [] { "orderingapi" } } - }); - } - } - } -} \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs b/src/Services/Ordering/Ordering.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs deleted file mode 100644 index 4c4207502..000000000 --- a/src/Services/Ordering/Ordering.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs +++ /dev/null @@ -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); - } - } - } -} diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs b/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs index 53c53f052..b9bc5cde9 100644 --- a/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs +++ b/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs @@ -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 async Task SeedAsync(OrderingContext context, IHostingEnvironment env,IOptions settings, ILogger logger) diff --git a/src/Services/Ordering/Ordering.API/Ordering.API.csproj b/src/Services/Ordering/Ordering.API/Ordering.API.csproj index 01c95761d..9d8569373 100644 --- a/src/Services/Ordering/Ordering.API/Ordering.API.csproj +++ b/src/Services/Ordering/Ordering.API/Ordering.API.csproj @@ -24,6 +24,8 @@ + + @@ -56,4 +58,8 @@ + + + + diff --git a/src/Services/Ordering/Ordering.API/Startup.cs b/src/Services/Ordering/Ordering.API/Startup.cs index 1879175c9..09988b740 100644 --- a/src/Services/Ordering/Ordering.API/Startup.cs +++ b/src/Services/Ordering/Ordering.API/Startup.cs @@ -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 Startup(IConfiguration configuration) @@ -53,7 +54,7 @@ // Add framework services. services.AddMvc(options => { - options.Filters.Add(typeof(HttpGlobalExceptionFilter)); + options.Filters.Add(typeof(HttpGlobalExceptionFilter)); }).AddControllersAsServices(); //Injecting Controllers themselves thru DI //For further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services diff --git a/src/Web/WebMVC/ByPassAuthMiddleware.cs b/src/Web/WebMVC/ByPassAuthMiddleware.cs new file mode 100644 index 000000000..e059be5ec --- /dev/null +++ b/src/Web/WebMVC/ByPassAuthMiddleware.cs @@ -0,0 +1,6 @@ +namespace Microsoft.eShopOnContainers.WebMVC +{ + internal class ByPassAuthMiddleware + { + } +} \ No newline at end of file diff --git a/src/Web/WebMVC/Controllers/CampaignsController.cs b/src/Web/WebMVC/Controllers/CampaignsController.cs index 058012d26..812034d08 100644 --- a/src/Web/WebMVC/Controllers/CampaignsController.cs +++ b/src/Web/WebMVC/Controllers/CampaignsController.cs @@ -8,7 +8,8 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers using Microsoft.Extensions.Options; using Services; using System; - using System.Threading.Tasks; + using System.Linq; + using System.Threading.Tasks; using ViewModels; using ViewModels.Pagination; @@ -43,7 +44,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers PaginationInfo = new PaginationInfo { ActualPage = page, - ItemsPerPage = campaignList.Data.Count, + ItemsPerPage = campaignList.Data.Count(), TotalItems = campaignList.Count, TotalPages = totalPages, Next = page == totalPages - 1 ? "is-disabled" : "", diff --git a/src/Web/WebMVC/Controllers/CatalogController.cs b/src/Web/WebMVC/Controllers/CatalogController.cs index 9e0859858..75c3a3f49 100644 --- a/src/Web/WebMVC/Controllers/CatalogController.cs +++ b/src/Web/WebMVC/Controllers/CatalogController.cs @@ -5,6 +5,7 @@ using Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination; using Microsoft.eShopOnContainers.WebMVC.Services; using Microsoft.eShopOnContainers.WebMVC.ViewModels.CatalogViewModels; using Microsoft.AspNetCore.Http; +using System.Linq; namespace Microsoft.eShopOnContainers.WebMVC.Controllers { @@ -29,7 +30,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers PaginationInfo = new PaginationInfo() { ActualPage = page ?? 0, - ItemsPerPage = catalog.Data.Count, + ItemsPerPage = catalog.Data.Count(), TotalItems = catalog.Count, TotalPages = (int)Math.Ceiling(((decimal)catalog.Count / itemsPage)) } diff --git a/src/Web/WebMVC/Infrastructure/Middlewares/ByPassAuthMiddleware.cs b/src/Web/WebMVC/Infrastructure/Middlewares/ByPassAuthMiddleware.cs deleted file mode 100644 index 72adaaa4d..000000000 --- a/src/Web/WebMVC/Infrastructure/Middlewares/ByPassAuthMiddleware.cs +++ /dev/null @@ -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); - } - } - } -} diff --git a/src/Web/WebMVC/Services/CampaignService.cs b/src/Web/WebMVC/Services/CampaignService.cs index 6190e74d6..69c56dd3e 100644 --- a/src/Web/WebMVC/Services/CampaignService.cs +++ b/src/Web/WebMVC/Services/CampaignService.cs @@ -10,8 +10,9 @@ using Newtonsoft.Json; using System; using System.Threading.Tasks; + using Microsoft.eShopOnContainers.Services.Common.API; - public class CampaignService : ICampaignService + public class CampaignService : ICampaignService { private readonly IOptionsSnapshot _settings; private readonly IHttpClient _apiClient; @@ -30,7 +31,7 @@ _httpContextAccesor = httpContextAccesor ?? throw new ArgumentNullException(nameof(httpContextAccesor)); } - public async Task GetCampaigns(int pageSize, int pageIndex) + public async Task> GetCampaigns(int pageSize, int pageIndex) { var allCampaignItemsUri = API.Marketing.GetAllCampaigns(_remoteServiceBaseUrl, pageSize, pageIndex); @@ -38,7 +39,7 @@ var authorizationToken = await GetUserTokenAsync(); var dataString = await _apiClient.GetStringAsync(allCampaignItemsUri, authorizationToken); - var response = JsonConvert.DeserializeObject(dataString); + var response = JsonConvert.DeserializeObject>(dataString); return response; } diff --git a/src/Web/WebMVC/Services/CatalogService.cs b/src/Web/WebMVC/Services/CatalogService.cs index 2af428e2e..e2e09f3b0 100644 --- a/src/Web/WebMVC/Services/CatalogService.cs +++ b/src/Web/WebMVC/Services/CatalogService.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.eShopOnContainers.BuildingBlocks.Resilience.Http; +using Microsoft.eShopOnContainers.Services.Common.API; using Microsoft.eShopOnContainers.WebMVC.ViewModels; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -28,13 +29,13 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services _remoteServiceBaseUrl = $"{_settings.Value.CatalogUrl}/api/v1/catalog/"; } - public async Task GetCatalogItems(int page, int take, int? brand, int? type) + public async Task> GetCatalogItems(int page, int take, int? brand, int? type) { var allcatalogItemsUri = API.Catalog.GetAllCatalogItems(_remoteServiceBaseUrl, page, take, brand, type); var dataString = await _apiClient.GetStringAsync(allcatalogItemsUri); - var response = JsonConvert.DeserializeObject(dataString); + var response = JsonConvert.DeserializeObject>(dataString); return response; } diff --git a/src/Web/WebMVC/Services/ICampaignService.cs b/src/Web/WebMVC/Services/ICampaignService.cs index ab80e930a..f12e30ad7 100644 --- a/src/Web/WebMVC/Services/ICampaignService.cs +++ b/src/Web/WebMVC/Services/ICampaignService.cs @@ -1,12 +1,13 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services { - using System.Collections.Generic; + using Microsoft.eShopOnContainers.Services.Common.API; + using System.Collections.Generic; using System.Threading.Tasks; using ViewModels; public interface ICampaignService { - Task GetCampaigns(int pageSize, int pageIndex); + Task> GetCampaigns(int pageSize, int pageIndex); Task GetCampaignById(int id); } diff --git a/src/Web/WebMVC/Services/ICatalogService.cs b/src/Web/WebMVC/Services/ICatalogService.cs index b126168fd..4abd8ab18 100644 --- a/src/Web/WebMVC/Services/ICatalogService.cs +++ b/src/Web/WebMVC/Services/ICatalogService.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.eShopOnContainers.Services.Common.API; using Microsoft.eShopOnContainers.WebMVC.ViewModels; using System; using System.Collections.Generic; @@ -9,7 +10,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services { public interface ICatalogService { - Task GetCatalogItems(int page, int take, int? brand, int? type); + Task> GetCatalogItems(int page, int take, int? brand, int? type); Task> GetBrands(); Task> GetTypes(); } diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs index 105b1ed9e..128034ca0 100644 --- a/src/Web/WebMVC/Startup.cs +++ b/src/Web/WebMVC/Startup.cs @@ -18,7 +18,6 @@ using StackExchange.Redis; using System; using System.IdentityModel.Tokens.Jwt; using WebMVC.Infrastructure; -using WebMVC.Infrastructure.Middlewares; using WebMVC.Services; namespace Microsoft.eShopOnContainers.WebMVC diff --git a/src/Web/WebMVC/ViewModels/Campaign.cs b/src/Web/WebMVC/ViewModels/Campaign.cs deleted file mode 100644 index 11841fc3f..000000000 --- a/src/Web/WebMVC/ViewModels/Campaign.cs +++ /dev/null @@ -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 Data { get; set; } - } -} \ No newline at end of file diff --git a/src/Web/WebMVC/ViewModels/Pagination/PaginationInfo.cs b/src/Web/WebMVC/ViewModels/Pagination/PaginationInfo.cs index 0baf8e961..84eae7052 100644 --- a/src/Web/WebMVC/ViewModels/Pagination/PaginationInfo.cs +++ b/src/Web/WebMVC/ViewModels/Pagination/PaginationInfo.cs @@ -7,7 +7,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination { public class PaginationInfo { - public int TotalItems { get; set; } + public long TotalItems { get; set; } public int ItemsPerPage { get; set; } public int ActualPage { get; set; } public int TotalPages { get; set; } diff --git a/src/Web/WebMVC/WebMVC.csproj b/src/Web/WebMVC/WebMVC.csproj index 89c58bd50..c4076772b 100644 --- a/src/Web/WebMVC/WebMVC.csproj +++ b/src/Web/WebMVC/WebMVC.csproj @@ -42,10 +42,15 @@ + + + + + diff --git a/src/Web/WebSPA/WebSPA.csproj b/src/Web/WebSPA/WebSPA.csproj index b5274462c..b6aeb94b5 100644 --- a/src/Web/WebSPA/WebSPA.csproj +++ b/src/Web/WebSPA/WebSPA.csproj @@ -8,6 +8,7 @@ true wwwroot/dist/** $(DefaultItemExcludes);$(GeneratedItemPatterns) + 2.5 diff --git a/test/Services/FunctionalTests/Services/IntegrationEventsScenarios.cs b/test/Services/FunctionalTests/Services/IntegrationEventsScenarios.cs index fd270d159..2325616bb 100644 --- a/test/Services/FunctionalTests/Services/IntegrationEventsScenarios.cs +++ b/test/Services/FunctionalTests/Services/IntegrationEventsScenarios.cs @@ -2,7 +2,6 @@ using FunctionalTests.Services.Catalog; using Microsoft.eShopOnContainers.Services.Basket.API.Model; using Microsoft.eShopOnContainers.Services.Catalog.API.Model; -using Microsoft.eShopOnContainers.Services.Catalog.API.ViewModel; using Newtonsoft.Json; using System; using System.Linq; @@ -12,6 +11,7 @@ using System.Threading.Tasks; using Xunit; using System.Net.Http; using System.Threading; +using Microsoft.eShopOnContainers.Services.Common.API; namespace FunctionalTests.Services { diff --git a/test/Services/FunctionalTests/Services/Marketing/MarketingScenarios.cs b/test/Services/FunctionalTests/Services/Marketing/MarketingScenarios.cs index 4c808565b..1634883ac 100644 --- a/test/Services/FunctionalTests/Services/Marketing/MarketingScenarios.cs +++ b/test/Services/FunctionalTests/Services/Marketing/MarketingScenarios.cs @@ -11,7 +11,6 @@ using Xunit; using System.Collections.Generic; using Microsoft.eShopOnContainers.Services.Marketing.API.Dto; - using Microsoft.eShopOnContainers.Services.Catalog.API.ViewModel; public class MarketingScenarios : MarketingScenariosBase { diff --git a/test/Services/UnitTest/Catalog/Application/CatalogControllerTest.cs b/test/Services/UnitTest/Catalog/Application/CatalogControllerTest.cs index 58d32c212..b20834e4b 100644 --- a/test/Services/UnitTest/Catalog/Application/CatalogControllerTest.cs +++ b/test/Services/UnitTest/Catalog/Application/CatalogControllerTest.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Microsoft.eShopOnContainers.Services.Common.API; using Microsoft.eShopOnContainers.WebMVC.Controllers; using Microsoft.eShopOnContainers.WebMVC.Services; using Microsoft.eShopOnContainers.WebMVC.ViewModels; @@ -7,7 +8,7 @@ using Moq; using System.Collections.Generic; using System.Threading.Tasks; using Xunit; -using CatalogModel = Microsoft.eShopOnContainers.WebMVC.ViewModels.Catalog; +using CatalogModel = Microsoft.eShopOnContainers.Services.Common.API.PaginatedItemsViewModel; namespace UnitTest.Catalog.Application { @@ -56,35 +57,29 @@ namespace UnitTest.Catalog.Application Assert.Empty(model.PaginationInfo.Previous); } - private CatalogModel GetFakeCatalog() + private PaginatedItemsViewModel GetFakeCatalog() { - return new CatalogModel() - { - PageSize = 10, - Count = 50, - PageIndex = 2, - Data = new List() - { - 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(2, 10, 50, new List + { + new CatalogItem() + { + Id = "1", + Name = "fakeItemA", + CatalogTypeId = 1 + }, + new CatalogItem() + { + Id = "2", + Name = "fakeItemB", + CatalogTypeId = 1 + }, + new CatalogItem() + { + Id = "3", + Name = "fakeItemC", + CatalogTypeId = 1 + } + }); } } }