diff --git a/HelloShop.sln b/HelloShop.sln index 3c1be0d..a4eec76 100644 --- a/HelloShop.sln +++ b/HelloShop.sln @@ -1,4 +1,5 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 + +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.9.34414.90 MinimumVisualStudioVersion = 10.0.40219.1 @@ -26,6 +27,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloShop.ProductService.Un EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloShop.ProductService.FunctionalTests", "tests\HelloShop.ProductService.FunctionalTests\HelloShop.ProductService.FunctionalTests.csproj", "{45932B7F-6ED0-40F3-AA2C-F14A844FEE18}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloShop.HybridApp", "src\HelloShop.HybridApp\HelloShop.HybridApp.csproj", "{E58F82E2-2E48-459B-A40E-497F24FC6DC1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloShop.FunctionalTests", "tests\HelloShop.FunctionalTests\HelloShop.FunctionalTests.csproj", "{6BAA9747-E0D0-41B9-8A1B-88B777498C43}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -72,6 +77,16 @@ Global {45932B7F-6ED0-40F3-AA2C-F14A844FEE18}.Debug|Any CPU.Build.0 = Debug|Any CPU {45932B7F-6ED0-40F3-AA2C-F14A844FEE18}.Release|Any CPU.ActiveCfg = Release|Any CPU {45932B7F-6ED0-40F3-AA2C-F14A844FEE18}.Release|Any CPU.Build.0 = Release|Any CPU + {E58F82E2-2E48-459B-A40E-497F24FC6DC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E58F82E2-2E48-459B-A40E-497F24FC6DC1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E58F82E2-2E48-459B-A40E-497F24FC6DC1}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {E58F82E2-2E48-459B-A40E-497F24FC6DC1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E58F82E2-2E48-459B-A40E-497F24FC6DC1}.Release|Any CPU.Build.0 = Release|Any CPU + {E58F82E2-2E48-459B-A40E-497F24FC6DC1}.Release|Any CPU.Deploy.0 = Release|Any CPU + {6BAA9747-E0D0-41B9-8A1B-88B777498C43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6BAA9747-E0D0-41B9-8A1B-88B777498C43}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6BAA9747-E0D0-41B9-8A1B-88B777498C43}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6BAA9747-E0D0-41B9-8A1B-88B777498C43}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -87,6 +102,8 @@ Global {02EBA5AD-84B4-4AF4-B519-72061C08800D} = {1AD03316-A743-4E9D-B3BC-FB9499D15141} {2022279A-E39F-4489-82AE-39AC53C594C9} = {29BE158E-825E-48AB-A02D-4E537A5DC502} {45932B7F-6ED0-40F3-AA2C-F14A844FEE18} = {29BE158E-825E-48AB-A02D-4E537A5DC502} + {E58F82E2-2E48-459B-A40E-497F24FC6DC1} = {1AD03316-A743-4E9D-B3BC-FB9499D15141} + {6BAA9747-E0D0-41B9-8A1B-88B777498C43} = {29BE158E-825E-48AB-A02D-4E537A5DC502} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {845545A8-2006-46C3-ABD7-5BDF63F3858C} diff --git a/src/HelloShop.ApiService/Controllers/PermissionsController.cs b/src/HelloShop.ApiService/Controllers/PermissionsController.cs index 5c4d31c..e7b7f2d 100644 --- a/src/HelloShop.ApiService/Controllers/PermissionsController.cs +++ b/src/HelloShop.ApiService/Controllers/PermissionsController.cs @@ -1,4 +1,7 @@ -using HelloShop.ApiService.Services; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ApiService.Services; using HelloShop.ServiceDefaults.Permissions; using Microsoft.AspNetCore.Mvc; diff --git a/src/HelloShop.ApiService/Controllers/ValuesController.cs b/src/HelloShop.ApiService/Controllers/ValuesController.cs index 8ba4f15..543efad 100644 --- a/src/HelloShop.ApiService/Controllers/ValuesController.cs +++ b/src/HelloShop.ApiService/Controllers/ValuesController.cs @@ -1,4 +1,7 @@ -using Microsoft.AspNetCore.Mvc; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.AspNetCore.Mvc; namespace HelloShop.ApiService.Controllers; diff --git a/src/HelloShop.ApiService/Extensions/OpenApiConfigureOptions.cs b/src/HelloShop.ApiService/Extensions/OpenApiConfigureOptions.cs index 80d9272..221a2d3 100644 --- a/src/HelloShop.ApiService/Extensions/OpenApiConfigureOptions.cs +++ b/src/HelloShop.ApiService/Extensions/OpenApiConfigureOptions.cs @@ -1,10 +1,13 @@ -using HelloShop.ApiService.Infrastructure; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ApiService.Infrastructure; using Microsoft.Extensions.Options; using Swashbuckle.AspNetCore.SwaggerUI; namespace HelloShop.ApiService.Extensions; -public class OpenApiConfigureOptions(IConfiguredServiceEndPointResolver serviceResolver, HttpClient httpClient) : IConfigureOptions +public class OpenApiConfigureOptions(IConfiguredServiceEndPointResolver serviceResolver, HttpClient httpClient, ILogger logger) : IConfigureOptions { public void Configure(SwaggerUIOptions options) { @@ -16,21 +19,27 @@ public class OpenApiConfigureOptions(IConfiguredServiceEndPointResolver serviceR { UriBuilder uriBuilder = new(endPoint) { Path = "swagger/v1/swagger.json" }; - HttpResponseMessage response = httpClient.GetAsync(uriBuilder.Uri).GetAwaiter().GetResult(); - - if (response.IsSuccessStatusCode) + try { - urlDescriptors.Add(new UrlDescriptor + HttpResponseMessage response = httpClient.GetAsync(uriBuilder.Uri).GetAwaiter().GetResult(); + if (response.IsSuccessStatusCode) { - Url = uriBuilder.Uri.ToString(), - Name = serviceEndpoint.ServiceName - }); - break; + urlDescriptors.Add(new UrlDescriptor + { + Url = uriBuilder.Uri.ToString(), + Name = serviceEndpoint.ServiceName + }); + break; + } + } + catch (Exception ex) + { + logger.LogError(ex, "Failed to get swagger endpoint for {ServiceName}", serviceEndpoint.ServiceName); } } } options.ConfigObject.Urls = urlDescriptors; - + options.SwaggerEndpoint("v1/swagger.json", "apiservice"); } } diff --git a/src/HelloShop.ApiService/HelloShop.ApiService.csproj b/src/HelloShop.ApiService/HelloShop.ApiService.csproj index 2f99c2c..f6b7233 100644 --- a/src/HelloShop.ApiService/HelloShop.ApiService.csproj +++ b/src/HelloShop.ApiService/HelloShop.ApiService.csproj @@ -1,7 +1,7 @@ - + Exe - net9.0 + net8.0 enable enable @@ -9,7 +9,6 @@ - - + \ No newline at end of file diff --git a/src/HelloShop.ApiService/Infrastructure/ConfiguredServiceEndPoint.cs b/src/HelloShop.ApiService/Infrastructure/ConfiguredServiceEndPoint.cs index 85bae37..473c41d 100644 --- a/src/HelloShop.ApiService/Infrastructure/ConfiguredServiceEndPoint.cs +++ b/src/HelloShop.ApiService/Infrastructure/ConfiguredServiceEndPoint.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ApiService.Infrastructure +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ApiService.Infrastructure { public class ConfiguredServiceEndPoint { diff --git a/src/HelloShop.ApiService/Infrastructure/ConfiguredServiceEndPointResolver.cs b/src/HelloShop.ApiService/Infrastructure/ConfiguredServiceEndPointResolver.cs index 894b325..8adaf1b 100644 --- a/src/HelloShop.ApiService/Infrastructure/ConfiguredServiceEndPointResolver.cs +++ b/src/HelloShop.ApiService/Infrastructure/ConfiguredServiceEndPointResolver.cs @@ -1,10 +1,12 @@ - +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using Microsoft.Extensions.Options; -using Microsoft.Extensions.ServiceDiscovery.Abstractions; +using Microsoft.Extensions.ServiceDiscovery; namespace HelloShop.ApiService.Infrastructure; -public class ConfiguredServiceEndPointResolver(IConfiguration configuration, IOptions resolverOptions) : IConfiguredServiceEndPointResolver +public class ConfiguredServiceEndPointResolver(IConfiguration configuration, IOptions resolverOptions) : IConfiguredServiceEndPointResolver { private readonly Lazy> _serviceEndPoints = new(() => { diff --git a/src/HelloShop.ApiService/Infrastructure/CustomReverseProxyConfigProvider.cs b/src/HelloShop.ApiService/Infrastructure/CustomReverseProxyConfigProvider.cs index 824f09c..039880b 100644 --- a/src/HelloShop.ApiService/Infrastructure/CustomReverseProxyConfigProvider.cs +++ b/src/HelloShop.ApiService/Infrastructure/CustomReverseProxyConfigProvider.cs @@ -1,4 +1,7 @@ -using Yarp.ReverseProxy.Configuration; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Yarp.ReverseProxy.Configuration; using Yarp.ReverseProxy.LoadBalancing; namespace HelloShop.ApiService.Infrastructure; diff --git a/src/HelloShop.ApiService/Infrastructure/IConfiguredServiceEndPointResolver.cs b/src/HelloShop.ApiService/Infrastructure/IConfiguredServiceEndPointResolver.cs index 5dfdaaf..c103e1d 100644 --- a/src/HelloShop.ApiService/Infrastructure/IConfiguredServiceEndPointResolver.cs +++ b/src/HelloShop.ApiService/Infrastructure/IConfiguredServiceEndPointResolver.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ApiService.Infrastructure; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ApiService.Infrastructure; public interface IConfiguredServiceEndPointResolver { diff --git a/src/HelloShop.ApiService/Infrastructure/IReverseProxyConfigProvider.cs b/src/HelloShop.ApiService/Infrastructure/IReverseProxyConfigProvider.cs index f4bc04d..e33871a 100644 --- a/src/HelloShop.ApiService/Infrastructure/IReverseProxyConfigProvider.cs +++ b/src/HelloShop.ApiService/Infrastructure/IReverseProxyConfigProvider.cs @@ -1,4 +1,7 @@ -using Yarp.ReverseProxy.Configuration; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Yarp.ReverseProxy.Configuration; namespace HelloShop.ApiService.Infrastructure; diff --git a/src/HelloShop.ApiService/Program.cs b/src/HelloShop.ApiService/Program.cs index b93e105..4fadada 100644 --- a/src/HelloShop.ApiService/Program.cs +++ b/src/HelloShop.ApiService/Program.cs @@ -1,10 +1,13 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ApiService.Extensions; using HelloShop.ApiService.Infrastructure; -using Yarp.ReverseProxy.Configuration; +using HelloShop.ApiService.Services; using HelloShop.ServiceDefaults.Extensions; using Microsoft.Extensions.Options; using Swashbuckle.AspNetCore.SwaggerUI; -using HelloShop.ApiService.Extensions; -using HelloShop.ApiService.Services; +using Yarp.ReverseProxy.Configuration; var builder = WebApplication.CreateBuilder(args); diff --git a/src/HelloShop.ApiService/Properties/launchSettings.json b/src/HelloShop.ApiService/Properties/launchSettings.json index aa60afc..2a72670 100644 --- a/src/HelloShop.ApiService/Properties/launchSettings.json +++ b/src/HelloShop.ApiService/Properties/launchSettings.json @@ -6,10 +6,20 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "http://localhost:5391", + "applicationUrl": "http://localhost:8001", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:8101;http://localhost:8001", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } -} +} \ No newline at end of file diff --git a/src/HelloShop.ApiService/Services/IPermissionService.cs b/src/HelloShop.ApiService/Services/IPermissionService.cs index ab41573..9efc0ed 100644 --- a/src/HelloShop.ApiService/Services/IPermissionService.cs +++ b/src/HelloShop.ApiService/Services/IPermissionService.cs @@ -1,4 +1,7 @@ -using HelloShop.ServiceDefaults.Permissions; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ServiceDefaults.Permissions; namespace HelloShop.ApiService.Services; diff --git a/src/HelloShop.ApiService/Services/PermissionService.cs b/src/HelloShop.ApiService/Services/PermissionService.cs index 060385c..c3861e1 100644 --- a/src/HelloShop.ApiService/Services/PermissionService.cs +++ b/src/HelloShop.ApiService/Services/PermissionService.cs @@ -1,4 +1,7 @@ -using HelloShop.ApiService.Infrastructure; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ApiService.Infrastructure; using HelloShop.ServiceDefaults.Permissions; namespace HelloShop.ApiService.Services; @@ -13,7 +16,7 @@ public class PermissionService(HttpClient httpClient, IConfiguredServiceEndPoint IReadOnlyCollection serviceEndPoints = await serviceEndPointResolver.GetConfiguredServiceEndpointsAsync(cancellationToken); - await Parallel.ForEachAsync(serviceEndPoints, new ParallelOptions{ CancellationToken= cancellationToken}, async (serviceEndPoint, cancelToken) => + await Parallel.ForEachAsync(serviceEndPoints, new ParallelOptions { CancellationToken = cancellationToken }, async (serviceEndPoint, cancelToken) => { UriBuilder uriBuilder = new(serviceEndPoint.ServiceName) { Path = "api/Permissions/PermissionDefinitions" }; diff --git a/src/HelloShop.AppHost/HelloShop.AppHost.csproj b/src/HelloShop.AppHost/HelloShop.AppHost.csproj index 960fddb..2a4cfa8 100644 --- a/src/HelloShop.AppHost/HelloShop.AppHost.csproj +++ b/src/HelloShop.AppHost/HelloShop.AppHost.csproj @@ -1,7 +1,7 @@ - + Exe - net9.0 + net8.0 enable enable true @@ -15,6 +15,6 @@ - + \ No newline at end of file diff --git a/src/HelloShop.AppHost/Program.cs b/src/HelloShop.AppHost/Program.cs index ac376ef..fdef62a 100644 --- a/src/HelloShop.AppHost/Program.cs +++ b/src/HelloShop.AppHost/Program.cs @@ -1,8 +1,11 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + var builder = DistributedApplication.CreateBuilder(args); var identityService = builder.AddProject("identityservice"); -var orderingService=builder.AddProject("orderingservice").WithReference(identityService); +var orderingService = builder.AddProject("orderingservice").WithReference(identityService); var productService = builder.AddProject("productservice").WithReference(identityService); diff --git a/src/HelloShop.AppHost/Properties/launchSettings.json b/src/HelloShop.AppHost/Properties/launchSettings.json index f9237f9..a9cb6a5 100644 --- a/src/HelloShop.AppHost/Properties/launchSettings.json +++ b/src/HelloShop.AppHost/Properties/launchSettings.json @@ -1,16 +1,29 @@ { - "$schema": "http://json.schemastore.org/launchsettings.json", + "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:8100;http://localhost:8000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21017", + "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22002" + } + }, "http": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "http://localhost:15016", + "applicationUrl": "http://localhost:8000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", "DOTNET_ENVIRONMENT": "Development", - "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16173" + "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19004", + "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20155" } } } -} +} \ No newline at end of file diff --git a/src/HelloShop.BasketService/HelloShop.BasketService.csproj b/src/HelloShop.BasketService/HelloShop.BasketService.csproj index f7efd5f..f7f620c 100644 --- a/src/HelloShop.BasketService/HelloShop.BasketService.csproj +++ b/src/HelloShop.BasketService/HelloShop.BasketService.csproj @@ -1,6 +1,6 @@ - net9.0 + net8.0 enable enable @@ -8,7 +8,7 @@ - + diff --git a/src/HelloShop.BasketService/Program.cs b/src/HelloShop.BasketService/Program.cs index 57871af..c23d283 100644 --- a/src/HelloShop.BasketService/Program.cs +++ b/src/HelloShop.BasketService/Program.cs @@ -1,4 +1,8 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using HelloShop.BasketService.Services; +using HelloShop.ServiceDefaults.Extensions; var builder = WebApplication.CreateBuilder(args); diff --git a/src/HelloShop.BasketService/Properties/launchSettings.json b/src/HelloShop.BasketService/Properties/launchSettings.json index 034dd47..4938073 100644 --- a/src/HelloShop.BasketService/Properties/launchSettings.json +++ b/src/HelloShop.BasketService/Properties/launchSettings.json @@ -5,7 +5,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": false, - "applicationUrl": "http://localhost:5079", + "applicationUrl": "http://localhost:8004", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -14,10 +14,10 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": false, - "applicationUrl": "https://localhost:7022;http://localhost:5079", + "applicationUrl": "https://localhost:8104;http://localhost:8004", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } -} +} \ No newline at end of file diff --git a/src/HelloShop.BasketService/Services/GreeterService.cs b/src/HelloShop.BasketService/Services/GreeterService.cs index 72dd36b..7722524 100644 --- a/src/HelloShop.BasketService/Services/GreeterService.cs +++ b/src/HelloShop.BasketService/Services/GreeterService.cs @@ -1,5 +1,7 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using Grpc.Core; -using HelloShop.BasketService; namespace HelloShop.BasketService.Services; diff --git a/src/HelloShop.BasketService/appsettings.json b/src/HelloShop.BasketService/appsettings.json index 1aef507..ec04bc1 100644 --- a/src/HelloShop.BasketService/appsettings.json +++ b/src/HelloShop.BasketService/appsettings.json @@ -5,10 +5,5 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*", - "Kestrel": { - "EndpointDefaults": { - "Protocols": "Http2" - } - } -} + "AllowedHosts": "*" +} \ No newline at end of file diff --git a/src/HelloShop.HybridApp/App.xaml b/src/HelloShop.HybridApp/App.xaml index 8a0b19a..32660a1 100644 --- a/src/HelloShop.HybridApp/App.xaml +++ b/src/HelloShop.HybridApp/App.xaml @@ -1,4 +1,4 @@ - + - + diff --git a/src/HelloShop.HybridApp/_Imports.razor b/src/HelloShop.HybridApp/Components/_Imports.razor similarity index 100% rename from src/HelloShop.HybridApp/_Imports.razor rename to src/HelloShop.HybridApp/Components/_Imports.razor diff --git a/src/HelloShop.HybridApp/HelloShop.HybridApp.csproj b/src/HelloShop.HybridApp/HelloShop.HybridApp.csproj index a60a52f..0c4194e 100644 --- a/src/HelloShop.HybridApp/HelloShop.HybridApp.csproj +++ b/src/HelloShop.HybridApp/HelloShop.HybridApp.csproj @@ -1,53 +1,67 @@  - - net9.0-android;net9.0-ios;net9.0-maccatalyst - $(TargetFrameworks);net9.0-windows10.0.19041.0 - - - + + + - - Exe - HelloShop.HybridApp - true - true - enable - false - enable - - HelloShop.HybridApp - - com.companyname.helloshop.hybridapp - - 1.0 - 1 - 14.2 - 14.0 - 24.0 - 10.0.17763.0 - 10.0.17763.0 - 6.5 - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + Exe + HelloShop.HybridApp + true + true + enable + false + enable + + + HelloShop.HybridApp + + + com.companyname.helloshop.hybridapp + + + 1.0 + 1 + + 14.2 + 14.0 + 24.0 + 10.0.17763.0 + 10.0.17763.0 + 6.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/HelloShop.HybridApp/MainPage.xaml b/src/HelloShop.HybridApp/MainPage.xaml index ef0446a..c579936 100644 --- a/src/HelloShop.HybridApp/MainPage.xaml +++ b/src/HelloShop.HybridApp/MainPage.xaml @@ -1,4 +1,4 @@ - + - + diff --git a/src/HelloShop.HybridApp/MainPage.xaml.cs b/src/HelloShop.HybridApp/MainPage.xaml.cs index c00adf5..661bb84 100644 --- a/src/HelloShop.HybridApp/MainPage.xaml.cs +++ b/src/HelloShop.HybridApp/MainPage.xaml.cs @@ -1,4 +1,7 @@ -namespace HelloShop.HybridApp +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.HybridApp { public partial class MainPage : ContentPage { diff --git a/src/HelloShop.HybridApp/MauiProgram.cs b/src/HelloShop.HybridApp/MauiProgram.cs index 2e2d74f..37d7ddb 100644 --- a/src/HelloShop.HybridApp/MauiProgram.cs +++ b/src/HelloShop.HybridApp/MauiProgram.cs @@ -1,4 +1,7 @@ -using Microsoft.Extensions.Logging; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.Extensions.Logging; namespace HelloShop.HybridApp { @@ -17,8 +20,8 @@ namespace HelloShop.HybridApp builder.Services.AddMauiBlazorWebView(); #if DEBUG - builder.Services.AddBlazorWebViewDeveloperTools(); - builder.Logging.AddDebug(); + builder.Services.AddBlazorWebViewDeveloperTools(); + builder.Logging.AddDebug(); #endif return builder.Build(); diff --git a/src/HelloShop.HybridApp/Platforms/Android/MainActivity.cs b/src/HelloShop.HybridApp/Platforms/Android/MainActivity.cs index ddfbf54..ec136df 100644 --- a/src/HelloShop.HybridApp/Platforms/Android/MainActivity.cs +++ b/src/HelloShop.HybridApp/Platforms/Android/MainActivity.cs @@ -1,6 +1,8 @@ -using Android.App; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Android.App; using Android.Content.PM; -using Android.OS; namespace HelloShop.HybridApp { diff --git a/src/HelloShop.HybridApp/Platforms/Android/MainApplication.cs b/src/HelloShop.HybridApp/Platforms/Android/MainApplication.cs index ee7ca8c..b031eb9 100644 --- a/src/HelloShop.HybridApp/Platforms/Android/MainApplication.cs +++ b/src/HelloShop.HybridApp/Platforms/Android/MainApplication.cs @@ -1,4 +1,7 @@ -using Android.App; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Android.App; using Android.Runtime; namespace HelloShop.HybridApp diff --git a/src/HelloShop.HybridApp/Platforms/MacCatalyst/AppDelegate.cs b/src/HelloShop.HybridApp/Platforms/MacCatalyst/AppDelegate.cs index 7f520ea..b948df0 100644 --- a/src/HelloShop.HybridApp/Platforms/MacCatalyst/AppDelegate.cs +++ b/src/HelloShop.HybridApp/Platforms/MacCatalyst/AppDelegate.cs @@ -1,4 +1,7 @@ -using Foundation; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Foundation; namespace HelloShop.HybridApp { diff --git a/src/HelloShop.HybridApp/Platforms/MacCatalyst/Program.cs b/src/HelloShop.HybridApp/Platforms/MacCatalyst/Program.cs index b5ecfb0..565363e 100644 --- a/src/HelloShop.HybridApp/Platforms/MacCatalyst/Program.cs +++ b/src/HelloShop.HybridApp/Platforms/MacCatalyst/Program.cs @@ -1,4 +1,6 @@ -using ObjCRuntime; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using UIKit; namespace HelloShop.HybridApp diff --git a/src/HelloShop.HybridApp/Platforms/Tizen/Main.cs b/src/HelloShop.HybridApp/Platforms/Tizen/Main.cs index 019220e..d683034 100644 --- a/src/HelloShop.HybridApp/Platforms/Tizen/Main.cs +++ b/src/HelloShop.HybridApp/Platforms/Tizen/Main.cs @@ -1,3 +1,6 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using Microsoft.Maui; using Microsoft.Maui.Hosting; using System; diff --git a/src/HelloShop.HybridApp/Platforms/Tizen/tizen-manifest.xml b/src/HelloShop.HybridApp/Platforms/Tizen/tizen-manifest.xml index f5bb6e4..8848796 100644 --- a/src/HelloShop.HybridApp/Platforms/Tizen/tizen-manifest.xml +++ b/src/HelloShop.HybridApp/Platforms/Tizen/tizen-manifest.xml @@ -1,5 +1,5 @@  - + diff --git a/src/HelloShop.HybridApp/Platforms/Windows/App.xaml b/src/HelloShop.HybridApp/Platforms/Windows/App.xaml index 020688b..ad0a76e 100644 --- a/src/HelloShop.HybridApp/Platforms/Windows/App.xaml +++ b/src/HelloShop.HybridApp/Platforms/Windows/App.xaml @@ -1,4 +1,4 @@ - - + $placeholder$ diff --git a/src/HelloShop.HybridApp/Platforms/iOS/AppDelegate.cs b/src/HelloShop.HybridApp/Platforms/iOS/AppDelegate.cs index 7f520ea..b948df0 100644 --- a/src/HelloShop.HybridApp/Platforms/iOS/AppDelegate.cs +++ b/src/HelloShop.HybridApp/Platforms/iOS/AppDelegate.cs @@ -1,4 +1,7 @@ -using Foundation; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Foundation; namespace HelloShop.HybridApp { diff --git a/src/HelloShop.HybridApp/Platforms/iOS/Program.cs b/src/HelloShop.HybridApp/Platforms/iOS/Program.cs index 33c29be..c3c2d3f 100644 --- a/src/HelloShop.HybridApp/Platforms/iOS/Program.cs +++ b/src/HelloShop.HybridApp/Platforms/iOS/Program.cs @@ -1,4 +1,6 @@ -using ObjCRuntime; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using UIKit; namespace HelloShop.HybridApp diff --git a/src/HelloShop.HybridApp/Resources/Fonts/OpenSans-Regular.ttf b/src/HelloShop.HybridApp/Resources/Fonts/OpenSans-Regular.ttf index 73954df..e54eba8 100644 Binary files a/src/HelloShop.HybridApp/Resources/Fonts/OpenSans-Regular.ttf and b/src/HelloShop.HybridApp/Resources/Fonts/OpenSans-Regular.ttf differ diff --git a/src/HelloShop.HybridApp/Resources/Raw/AboutAssets.txt b/src/HelloShop.HybridApp/Resources/Raw/AboutAssets.txt index 531df33..6de1c15 100644 --- a/src/HelloShop.HybridApp/Resources/Raw/AboutAssets.txt +++ b/src/HelloShop.HybridApp/Resources/Raw/AboutAssets.txt @@ -4,7 +4,7 @@ is automatically handled by the following `MauiAsset` Build Action within your ` -These files will be deployed with you package and will be accessible using Essentials: +These files will be deployed with your package and will be accessible using Essentials: async Task LoadMauiAsset() { diff --git a/src/HelloShop.IdentityService/Authentication/CustomJwtBearerDefaults.cs b/src/HelloShop.IdentityService/Authentication/CustomJwtBearerDefaults.cs index b28ad3f..3de91cb 100644 --- a/src/HelloShop.IdentityService/Authentication/CustomJwtBearerDefaults.cs +++ b/src/HelloShop.IdentityService/Authentication/CustomJwtBearerDefaults.cs @@ -1,4 +1,7 @@ -namespace HelloShop.IdentityService; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.IdentityService; public class CustomJwtBearerDefaults { diff --git a/src/HelloShop.IdentityService/Authentication/CustomJwtBearerExtensions.cs b/src/HelloShop.IdentityService/Authentication/CustomJwtBearerExtensions.cs index 6081b7f..c544527 100644 --- a/src/HelloShop.IdentityService/Authentication/CustomJwtBearerExtensions.cs +++ b/src/HelloShop.IdentityService/Authentication/CustomJwtBearerExtensions.cs @@ -1,4 +1,7 @@ -using HelloShop.IdentityService.Entities; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.IdentityService.Entities; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Identity; diff --git a/src/HelloShop.IdentityService/Authentication/CustomJwtBearerHandler.cs b/src/HelloShop.IdentityService/Authentication/CustomJwtBearerHandler.cs index ef921a4..f5e86bd 100644 --- a/src/HelloShop.IdentityService/Authentication/CustomJwtBearerHandler.cs +++ b/src/HelloShop.IdentityService/Authentication/CustomJwtBearerHandler.cs @@ -1,4 +1,7 @@ -using Microsoft.AspNetCore.Authentication; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.BearerToken; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; diff --git a/src/HelloShop.IdentityService/Authentication/CustomJwtBearerOptions.cs b/src/HelloShop.IdentityService/Authentication/CustomJwtBearerOptions.cs index bca6bc3..394b9fc 100644 --- a/src/HelloShop.IdentityService/Authentication/CustomJwtBearerOptions.cs +++ b/src/HelloShop.IdentityService/Authentication/CustomJwtBearerOptions.cs @@ -1,4 +1,7 @@ -using Microsoft.AspNetCore.Authentication; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.AspNetCore.Authentication; using Microsoft.IdentityModel.Tokens; namespace HelloShop.IdentityService; diff --git a/src/HelloShop.IdentityService/Authentication/CustomUserClaimsPrincipalFactory.cs b/src/HelloShop.IdentityService/Authentication/CustomUserClaimsPrincipalFactory.cs index 053b05b..36cf815 100644 --- a/src/HelloShop.IdentityService/Authentication/CustomUserClaimsPrincipalFactory.cs +++ b/src/HelloShop.IdentityService/Authentication/CustomUserClaimsPrincipalFactory.cs @@ -1,4 +1,7 @@ -using HelloShop.ServiceDefaults.Constants; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ServiceDefaults.Constants; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Options; using System.Security.Claims; diff --git a/src/HelloShop.IdentityService/Authorization/LocalPermissionChecker.cs b/src/HelloShop.IdentityService/Authorization/LocalPermissionChecker.cs index 0ef87bf..c8a7a55 100644 --- a/src/HelloShop.IdentityService/Authorization/LocalPermissionChecker.cs +++ b/src/HelloShop.IdentityService/Authorization/LocalPermissionChecker.cs @@ -1,4 +1,7 @@ -using HelloShop.IdentityService.Entities; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.IdentityService.Entities; using HelloShop.IdentityService.EntityFrameworks; using HelloShop.ServiceDefaults.Authorization; using Microsoft.EntityFrameworkCore; diff --git a/src/HelloShop.IdentityService/AutoMapper/UsersMapConfiguration.cs b/src/HelloShop.IdentityService/AutoMapper/UsersMapConfiguration.cs index 11e0a24..a2fdfe8 100644 --- a/src/HelloShop.IdentityService/AutoMapper/UsersMapConfiguration.cs +++ b/src/HelloShop.IdentityService/AutoMapper/UsersMapConfiguration.cs @@ -1,7 +1,9 @@ -using AutoMapper; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using AutoMapper; using HelloShop.IdentityService.Entities; using HelloShop.IdentityService.Models.Users; -using Microsoft.Extensions.Options; namespace HelloShop.IdentityService.AutoMapper; diff --git a/src/HelloShop.IdentityService/Constants/DbConstants.cs b/src/HelloShop.IdentityService/Constants/DbConstants.cs index a2825ed..d640922 100644 --- a/src/HelloShop.IdentityService/Constants/DbConstants.cs +++ b/src/HelloShop.IdentityService/Constants/DbConstants.cs @@ -1,4 +1,7 @@ -namespace HelloShop.IdentityService.Constants +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.IdentityService.Constants { public class DbConstants { diff --git a/src/HelloShop.IdentityService/Controllers/AccountController.cs b/src/HelloShop.IdentityService/Controllers/AccountController.cs index d3c1c95..a8cb9ac 100644 --- a/src/HelloShop.IdentityService/Controllers/AccountController.cs +++ b/src/HelloShop.IdentityService/Controllers/AccountController.cs @@ -1,4 +1,7 @@ -using HelloShop.IdentityService.Entities; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.IdentityService.Entities; using Microsoft.AspNetCore.Authentication.BearerToken; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Http.HttpResults; diff --git a/src/HelloShop.IdentityService/Controllers/HelloWorldController.cs b/src/HelloShop.IdentityService/Controllers/HelloWorldController.cs index 5ecf733..2b18e31 100644 --- a/src/HelloShop.IdentityService/Controllers/HelloWorldController.cs +++ b/src/HelloShop.IdentityService/Controllers/HelloWorldController.cs @@ -1,6 +1,8 @@ -using Microsoft.AspNetCore.Mvc; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Localization; -using System.Globalization; using System.Reflection; namespace HelloShop.IdentityService.Controllers; diff --git a/src/HelloShop.IdentityService/Controllers/PermissionsController.cs b/src/HelloShop.IdentityService/Controllers/PermissionsController.cs index 4feef68..6b4da01 100644 --- a/src/HelloShop.IdentityService/Controllers/PermissionsController.cs +++ b/src/HelloShop.IdentityService/Controllers/PermissionsController.cs @@ -1,7 +1,8 @@ -using HelloShop.IdentityService.Entities; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.IdentityService.Entities; using HelloShop.IdentityService.EntityFrameworks; -using HelloShop.ServiceDefaults.Authorization; -using HelloShop.ServiceDefaults.Constants; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -9,12 +10,13 @@ using Microsoft.EntityFrameworkCore; [Route("api/[controller]")] [ApiController] [Authorize] -public class PermissionsController(IPermissionChecker permissionChecker) : ControllerBase +public class PermissionsController(IdentityServiceDbContext dbContext) : ControllerBase { [HttpHead] - public async Task CheckPermission(string permissionName, string? resourceType = null, string? resourceId = null) + public async Task CheckPermission(int roleId, string permissionName, string? resourceType = null, string? resourceId = null) { - if(await permissionChecker.IsGrantedAsync(permissionName, resourceType, resourceId)) + + if (await dbContext.Set().AnyAsync(x => x.RoleId == roleId && x.PermissionName == permissionName && x.ResourceType == resourceType && x.ResourceId == resourceId)) { return Ok(); } diff --git a/src/HelloShop.IdentityService/Controllers/UsersController.cs b/src/HelloShop.IdentityService/Controllers/UsersController.cs index ca8c727..3571b29 100644 --- a/src/HelloShop.IdentityService/Controllers/UsersController.cs +++ b/src/HelloShop.IdentityService/Controllers/UsersController.cs @@ -1,14 +1,17 @@ -using AutoMapper; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using AutoMapper; using FluentValidation; using HelloShop.IdentityService.Entities; using HelloShop.IdentityService.EntityFrameworks; using HelloShop.IdentityService.Models.Users; using HelloShop.ServiceDefaults.Authorization; +using HelloShop.ServiceDefaults.Extensions; using HelloShop.ServiceDefaults.Models.Paging; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; -using HelloShop.ServiceDefaults.Extensions; // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 @@ -28,7 +31,7 @@ namespace HelloShop.IdentityService.Controllers { users = users.Where(e => e.UserName != null && e.UserName.Contains(model.Keyword)); } - + users = users.WhereIf(model.PhoneNumber is not null, e => e.PhoneNumber == model.PhoneNumber); IQueryable pagedUsers = users.SortAndPageBy(model); diff --git a/src/HelloShop.IdentityService/Controllers/WeatherForecastController.cs b/src/HelloShop.IdentityService/Controllers/WeatherForecastController.cs index 9c21dba..1e5ee3b 100644 --- a/src/HelloShop.IdentityService/Controllers/WeatherForecastController.cs +++ b/src/HelloShop.IdentityService/Controllers/WeatherForecastController.cs @@ -1,3 +1,6 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using Microsoft.AspNetCore.Mvc; namespace HelloShop.IdentityService.Controllers; diff --git a/src/HelloShop.IdentityService/DataSeeding/UserDataSeedingProvider.cs b/src/HelloShop.IdentityService/DataSeeding/UserDataSeedingProvider.cs index 75f01e7..648ca0b 100644 --- a/src/HelloShop.IdentityService/DataSeeding/UserDataSeedingProvider.cs +++ b/src/HelloShop.IdentityService/DataSeeding/UserDataSeedingProvider.cs @@ -1,5 +1,7 @@ -using HelloShop.IdentityService.Entities; -using HelloShop.IdentityService.EntityFrameworks; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.IdentityService.Entities; using HelloShop.ServiceDefaults.Infrastructure; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; diff --git a/src/HelloShop.IdentityService/Entities/PermissionGranted.cs b/src/HelloShop.IdentityService/Entities/PermissionGranted.cs index e3634a1..dfd8269 100644 --- a/src/HelloShop.IdentityService/Entities/PermissionGranted.cs +++ b/src/HelloShop.IdentityService/Entities/PermissionGranted.cs @@ -1,4 +1,7 @@ -namespace HelloShop.IdentityService.Entities; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.IdentityService.Entities; public class PermissionGranted { diff --git a/src/HelloShop.IdentityService/Entities/Role.cs b/src/HelloShop.IdentityService/Entities/Role.cs index b1cb738..fb83cfc 100644 --- a/src/HelloShop.IdentityService/Entities/Role.cs +++ b/src/HelloShop.IdentityService/Entities/Role.cs @@ -5,8 +5,8 @@ using Microsoft.AspNetCore.Identity; namespace HelloShop.IdentityService.Entities { - public class Role: IdentityRole + public class Role : IdentityRole { - public DateTimeOffset CreationTime { get; set; }=TimeProvider.System.GetUtcNow(); + public DateTimeOffset CreationTime { get; set; } = TimeProvider.System.GetUtcNow(); } } diff --git a/src/HelloShop.IdentityService/Entities/User.cs b/src/HelloShop.IdentityService/Entities/User.cs index 028b7c3..fdfeacf 100644 --- a/src/HelloShop.IdentityService/Entities/User.cs +++ b/src/HelloShop.IdentityService/Entities/User.cs @@ -2,7 +2,6 @@ // See the license file in the project root for more information. using HelloShop.ServiceDefaults.Authorization; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; namespace HelloShop.IdentityService.Entities diff --git a/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/PermissionGrantedEntityTypeConfiguration.cs b/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/PermissionGrantedEntityTypeConfiguration.cs index 20c55a5..5087b2d 100644 --- a/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/PermissionGrantedEntityTypeConfiguration.cs +++ b/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/PermissionGrantedEntityTypeConfiguration.cs @@ -1,4 +1,7 @@ -using HelloShop.IdentityService.Entities; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.IdentityService.Entities; using Microsoft.EntityFrameworkCore; namespace HelloShop.IdentityService.EntityFrameworks.EntityConfigurations; diff --git a/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/RoleClaimEntityTypeConfiguration.cs b/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/RoleClaimEntityTypeConfiguration.cs index 646ab4b..c41239c 100644 --- a/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/RoleClaimEntityTypeConfiguration.cs +++ b/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/RoleClaimEntityTypeConfiguration.cs @@ -2,8 +2,8 @@ // See the license file in the project root for more information. using Microsoft.AspNetCore.Identity; -using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace HelloShop.IdentityService.EntityFrameworks.EntityConfigurations { diff --git a/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/RoleEntityTypeConfiguration.cs b/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/RoleEntityTypeConfiguration.cs index b042731..f27c24f 100644 --- a/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/RoleEntityTypeConfiguration.cs +++ b/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/RoleEntityTypeConfiguration.cs @@ -2,8 +2,8 @@ // See the license file in the project root for more information. using HelloShop.IdentityService.Entities; -using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace HelloShop.IdentityService.EntityFrameworks.EntityConfigurations { diff --git a/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserClaimEntityTypeConfiguration.cs b/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserClaimEntityTypeConfiguration.cs index b6642cd..f710067 100644 --- a/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserClaimEntityTypeConfiguration.cs +++ b/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserClaimEntityTypeConfiguration.cs @@ -2,8 +2,8 @@ // See the license file in the project root for more information. using Microsoft.AspNetCore.Identity; -using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace HelloShop.IdentityService.EntityFrameworks.EntityConfigurations { diff --git a/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserEntityTypeConfiguration.cs b/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserEntityTypeConfiguration.cs index 7593740..de7c7f6 100644 --- a/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserEntityTypeConfiguration.cs +++ b/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserEntityTypeConfiguration.cs @@ -1,4 +1,7 @@ -using HelloShop.IdentityService.Entities; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.IdentityService.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; diff --git a/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserLoginEntityTypeConfiguration.cs b/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserLoginEntityTypeConfiguration.cs index 7d4b6ea..7635ca5 100644 --- a/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserLoginEntityTypeConfiguration.cs +++ b/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserLoginEntityTypeConfiguration.cs @@ -2,8 +2,8 @@ // See the license file in the project root for more information. using Microsoft.AspNetCore.Identity; -using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace HelloShop.IdentityService.EntityFrameworks.EntityConfigurations { diff --git a/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserTokenEntityTypeConfiguration.cs b/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserTokenEntityTypeConfiguration.cs index 0c45fff..0840c61 100644 --- a/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserTokenEntityTypeConfiguration.cs +++ b/src/HelloShop.IdentityService/EntityFrameworks/EntityConfigurations/UserTokenEntityTypeConfiguration.cs @@ -2,8 +2,8 @@ // See the license file in the project root for more information. using Microsoft.AspNetCore.Identity; -using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace HelloShop.IdentityService.EntityFrameworks.EntityConfigurations { diff --git a/src/HelloShop.IdentityService/EntityFrameworks/IdentityServiceDbContext.cs b/src/HelloShop.IdentityService/EntityFrameworks/IdentityServiceDbContext.cs index 0882521..d477352 100644 --- a/src/HelloShop.IdentityService/EntityFrameworks/IdentityServiceDbContext.cs +++ b/src/HelloShop.IdentityService/EntityFrameworks/IdentityServiceDbContext.cs @@ -1,4 +1,7 @@ -using HelloShop.IdentityService.Entities; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.IdentityService.Entities; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using System.Reflection; diff --git a/src/HelloShop.IdentityService/EntityFrameworks/Migrations/20240403122821_InitialCreate.cs b/src/HelloShop.IdentityService/EntityFrameworks/Migrations/20240403122821_InitialCreate.cs index 68fb23e..777f742 100644 --- a/src/HelloShop.IdentityService/EntityFrameworks/Migrations/20240403122821_InitialCreate.cs +++ b/src/HelloShop.IdentityService/EntityFrameworks/Migrations/20240403122821_InitialCreate.cs @@ -1,4 +1,6 @@ -using System; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; diff --git a/src/HelloShop.IdentityService/HelloShop.IdentityService.csproj b/src/HelloShop.IdentityService/HelloShop.IdentityService.csproj index 96312b2..a8605af 100644 --- a/src/HelloShop.IdentityService/HelloShop.IdentityService.csproj +++ b/src/HelloShop.IdentityService/HelloShop.IdentityService.csproj @@ -1,23 +1,19 @@ - - net9.0 - enable - enable - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - - + + net8.0 + enable + enable + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + \ No newline at end of file diff --git a/src/HelloShop.IdentityService/Models/Accounts/AccountLoginRequest.cs b/src/HelloShop.IdentityService/Models/Accounts/AccountLoginRequest.cs index 297cbd1..7e8bb90 100644 --- a/src/HelloShop.IdentityService/Models/Accounts/AccountLoginRequest.cs +++ b/src/HelloShop.IdentityService/Models/Accounts/AccountLoginRequest.cs @@ -1,16 +1,19 @@ -using System.Text.Json.Serialization; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using System.Text.Json.Serialization; namespace HelloShop.IdentityService; public class AccountLoginRequest { - public required string UserName { get; init; } + public required string UserName { get; init; } - public required string Password { get; init; } + public required string Password { get; init; } - [JsonIgnore] - public string? TwoFactorCode { get; init; } + [JsonIgnore] + public string? TwoFactorCode { get; init; } - [JsonIgnore] - public string? TwoFactorRecoveryCode { get; init; } + [JsonIgnore] + public string? TwoFactorRecoveryCode { get; init; } } diff --git a/src/HelloShop.IdentityService/Models/Accounts/AccountRefreshRequest.cs b/src/HelloShop.IdentityService/Models/Accounts/AccountRefreshRequest.cs index 2175572..38f3e18 100644 --- a/src/HelloShop.IdentityService/Models/Accounts/AccountRefreshRequest.cs +++ b/src/HelloShop.IdentityService/Models/Accounts/AccountRefreshRequest.cs @@ -1,4 +1,7 @@ -namespace HelloShop.IdentityService; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.IdentityService; public class AccountRefreshRequest { diff --git a/src/HelloShop.IdentityService/Models/Accounts/AccountRegisterRequest.cs b/src/HelloShop.IdentityService/Models/Accounts/AccountRegisterRequest.cs index 2ca41cb..a165967 100644 --- a/src/HelloShop.IdentityService/Models/Accounts/AccountRegisterRequest.cs +++ b/src/HelloShop.IdentityService/Models/Accounts/AccountRegisterRequest.cs @@ -1,4 +1,7 @@ -namespace HelloShop.IdentityService; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.IdentityService; public class AccountRegisterRequest { diff --git a/src/HelloShop.IdentityService/Models/Users/UserCreateRequest.cs b/src/HelloShop.IdentityService/Models/Users/UserCreateRequest.cs index e303fee..f4b0160 100644 --- a/src/HelloShop.IdentityService/Models/Users/UserCreateRequest.cs +++ b/src/HelloShop.IdentityService/Models/Users/UserCreateRequest.cs @@ -1,5 +1,5 @@ -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. namespace HelloShop.IdentityService.Models.Users; diff --git a/src/HelloShop.IdentityService/Models/Users/UserDetailsResponse.cs b/src/HelloShop.IdentityService/Models/Users/UserDetailsResponse.cs index d325de3..1a57714 100644 --- a/src/HelloShop.IdentityService/Models/Users/UserDetailsResponse.cs +++ b/src/HelloShop.IdentityService/Models/Users/UserDetailsResponse.cs @@ -1,4 +1,7 @@ -namespace HelloShop.IdentityService.Models.Users; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.IdentityService.Models.Users; public class UserDetailsResponse { diff --git a/src/HelloShop.IdentityService/Models/Users/UserListItem.cs b/src/HelloShop.IdentityService/Models/Users/UserListItem.cs index e47b9e2..145a15e 100644 --- a/src/HelloShop.IdentityService/Models/Users/UserListItem.cs +++ b/src/HelloShop.IdentityService/Models/Users/UserListItem.cs @@ -1,4 +1,7 @@ -namespace HelloShop.IdentityService; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.IdentityService; public class UserListItem { diff --git a/src/HelloShop.IdentityService/Models/Users/UserListRequest.cs b/src/HelloShop.IdentityService/Models/Users/UserListRequest.cs index 69c8fdb..5dd6fef 100644 --- a/src/HelloShop.IdentityService/Models/Users/UserListRequest.cs +++ b/src/HelloShop.IdentityService/Models/Users/UserListRequest.cs @@ -1,4 +1,7 @@ -using HelloShop.ServiceDefaults.Models.Paging; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ServiceDefaults.Models.Paging; namespace HelloShop.IdentityService.Models.Users; diff --git a/src/HelloShop.IdentityService/Models/Users/UserUpdateRequest.cs b/src/HelloShop.IdentityService/Models/Users/UserUpdateRequest.cs index b0d4030..44adb16 100644 --- a/src/HelloShop.IdentityService/Models/Users/UserUpdateRequest.cs +++ b/src/HelloShop.IdentityService/Models/Users/UserUpdateRequest.cs @@ -1,4 +1,7 @@ -namespace HelloShop.IdentityService.Models.Users; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.IdentityService.Models.Users; public class UserUpdateRequest { diff --git a/src/HelloShop.IdentityService/PermissionProviders/IdentityPermissionDefinitionProvider.cs b/src/HelloShop.IdentityService/PermissionProviders/IdentityPermissionDefinitionProvider.cs index ff6f209..8ebde7c 100644 --- a/src/HelloShop.IdentityService/PermissionProviders/IdentityPermissionDefinitionProvider.cs +++ b/src/HelloShop.IdentityService/PermissionProviders/IdentityPermissionDefinitionProvider.cs @@ -1,4 +1,7 @@ -using HelloShop.ServiceDefaults.Permissions; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ServiceDefaults.Permissions; namespace HelloShop.IdentityService; diff --git a/src/HelloShop.IdentityService/PermissionProviders/IdentityPermissions.cs b/src/HelloShop.IdentityService/PermissionProviders/IdentityPermissions.cs index efc55e1..16cbb3d 100644 --- a/src/HelloShop.IdentityService/PermissionProviders/IdentityPermissions.cs +++ b/src/HelloShop.IdentityService/PermissionProviders/IdentityPermissions.cs @@ -1,4 +1,7 @@ -namespace HelloShop.IdentityService; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.IdentityService; public static class IdentityPermissions { diff --git a/src/HelloShop.IdentityService/Program.cs b/src/HelloShop.IdentityService/Program.cs index b0b25ab..72e5898 100644 --- a/src/HelloShop.IdentityService/Program.cs +++ b/src/HelloShop.IdentityService/Program.cs @@ -1,7 +1,9 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using HelloShop.IdentityService; using HelloShop.IdentityService.Authorization; using HelloShop.IdentityService.Constants; -using HelloShop.IdentityService.DataSeeding; using HelloShop.IdentityService.Entities; using HelloShop.IdentityService.EntityFrameworks; using HelloShop.ServiceDefaults.Authorization; @@ -64,8 +66,6 @@ var app = builder.Build(); app.MapDefaultEndpoints(); -app.UseHttpsRedirection(); - app.UseAuthorization(); app.UseCors(options => options.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); diff --git a/src/HelloShop.IdentityService/Properties/launchSettings.json b/src/HelloShop.IdentityService/Properties/launchSettings.json index d259642..114b576 100644 --- a/src/HelloShop.IdentityService/Properties/launchSettings.json +++ b/src/HelloShop.IdentityService/Properties/launchSettings.json @@ -1,20 +1,12 @@ { - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:20874", - "sslPort": 44391 - } - }, + "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { "http": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "http://localhost:5119", + "applicationUrl": "http://localhost:8002", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -24,18 +16,10 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "https://localhost:7266;http://localhost:5119", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", + "applicationUrl": "https://localhost:8102;http://localhost:8002", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } -} +} \ No newline at end of file diff --git a/src/HelloShop.IdentityService/Validations/Users/UserCreateRequestValidator.cs b/src/HelloShop.IdentityService/Validations/Users/UserCreateRequestValidator.cs index bb0f35c..0c276cb 100644 --- a/src/HelloShop.IdentityService/Validations/Users/UserCreateRequestValidator.cs +++ b/src/HelloShop.IdentityService/Validations/Users/UserCreateRequestValidator.cs @@ -1,4 +1,7 @@ -using FluentValidation; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using FluentValidation; using HelloShop.IdentityService.Entities; using HelloShop.IdentityService.EntityFrameworks; using HelloShop.IdentityService.Models.Users; @@ -9,7 +12,7 @@ namespace HelloShop.IdentityService.Validations.Users; public class UserCreateRequestValidator : AbstractValidator { - public UserCreateRequestValidator(IdentityServiceDbContext dbContext,IStringLocalizer localizer ) + public UserCreateRequestValidator(IdentityServiceDbContext dbContext, IStringLocalizer localizer) { RuleFor(m => m.UserName).NotNull().NotEmpty().Length(8, 16).Matches("^[a-zA-Z]+$"); diff --git a/src/HelloShop.IdentityService/Validations/Users/UserUpdateRequestValidator.cs b/src/HelloShop.IdentityService/Validations/Users/UserUpdateRequestValidator.cs index 399538b..dfc1a34 100644 --- a/src/HelloShop.IdentityService/Validations/Users/UserUpdateRequestValidator.cs +++ b/src/HelloShop.IdentityService/Validations/Users/UserUpdateRequestValidator.cs @@ -1,4 +1,7 @@ -using FluentValidation; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using FluentValidation; using HelloShop.IdentityService.Entities; using HelloShop.IdentityService.EntityFrameworks; using HelloShop.IdentityService.Models.Users; diff --git a/src/HelloShop.IdentityService/WeatherForecast.cs b/src/HelloShop.IdentityService/WeatherForecast.cs index fe85641..061ce26 100644 --- a/src/HelloShop.IdentityService/WeatherForecast.cs +++ b/src/HelloShop.IdentityService/WeatherForecast.cs @@ -1,3 +1,6 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + namespace HelloShop.IdentityService; public class WeatherForecast diff --git a/src/HelloShop.IdentityService/Welcome.cs b/src/HelloShop.IdentityService/Welcome.cs index 37177ad..7e08030 100644 --- a/src/HelloShop.IdentityService/Welcome.cs +++ b/src/HelloShop.IdentityService/Welcome.cs @@ -1,4 +1,7 @@ -namespace HelloShop.IdentityService; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.IdentityService; public class Welcome { diff --git a/src/HelloShop.OrderingService/Controllers/WeatherForecastController.cs b/src/HelloShop.OrderingService/Controllers/WeatherForecastController.cs index f1b265f..931046f 100644 --- a/src/HelloShop.OrderingService/Controllers/WeatherForecastController.cs +++ b/src/HelloShop.OrderingService/Controllers/WeatherForecastController.cs @@ -1,3 +1,6 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using Microsoft.AspNetCore.Mvc; namespace HelloShop.OrderingService.Controllers; diff --git a/src/HelloShop.OrderingService/HelloShop.OrderingService.csproj b/src/HelloShop.OrderingService/HelloShop.OrderingService.csproj index eeb933d..6aa8756 100644 --- a/src/HelloShop.OrderingService/HelloShop.OrderingService.csproj +++ b/src/HelloShop.OrderingService/HelloShop.OrderingService.csproj @@ -1,12 +1,9 @@ - net9.0 + net8.0 enable enable - - - diff --git a/src/HelloShop.OrderingService/Program.cs b/src/HelloShop.OrderingService/Program.cs index 49ee5eb..6f7bf8b 100644 --- a/src/HelloShop.OrderingService/Program.cs +++ b/src/HelloShop.OrderingService/Program.cs @@ -1,3 +1,6 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using HelloShop.ServiceDefaults.Extensions; var builder = WebApplication.CreateBuilder(args); @@ -13,8 +16,6 @@ var app = builder.Build(); app.MapDefaultEndpoints(); -app.UseHttpsRedirection(); - app.UseAuthorization(); app.UseCors(options => options.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); diff --git a/src/HelloShop.OrderingService/Properties/launchSettings.json b/src/HelloShop.OrderingService/Properties/launchSettings.json index bd2df88..ed3efeb 100644 --- a/src/HelloShop.OrderingService/Properties/launchSettings.json +++ b/src/HelloShop.OrderingService/Properties/launchSettings.json @@ -1,20 +1,12 @@ { - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:39547", - "sslPort": 44369 - } - }, + "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { "http": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "http://localhost:5015", + "applicationUrl": "http://localhost:8005", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -24,18 +16,10 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "https://localhost:7250;http://localhost:5015", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", + "applicationUrl": "https://localhost:8105;http://localhost:8005", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } -} +} \ No newline at end of file diff --git a/src/HelloShop.OrderingService/WeatherForecast.cs b/src/HelloShop.OrderingService/WeatherForecast.cs index 8622369..2ae343e 100644 --- a/src/HelloShop.OrderingService/WeatherForecast.cs +++ b/src/HelloShop.OrderingService/WeatherForecast.cs @@ -1,3 +1,6 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + namespace HelloShop.OrderingService; public class WeatherForecast diff --git a/src/HelloShop.ProductService/AutoMapper/ProductsMapConfiguration.cs b/src/HelloShop.ProductService/AutoMapper/ProductsMapConfiguration.cs index ce84097..0a8f51f 100644 --- a/src/HelloShop.ProductService/AutoMapper/ProductsMapConfiguration.cs +++ b/src/HelloShop.ProductService/AutoMapper/ProductsMapConfiguration.cs @@ -1,4 +1,7 @@ -using AutoMapper; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using AutoMapper; using HelloShop.ProductService.Entities.Products; using HelloShop.ProductService.Models.Products; diff --git a/src/HelloShop.ProductService/Constants/DbConstants.cs b/src/HelloShop.ProductService/Constants/DbConstants.cs index a07b029..165bfdc 100644 --- a/src/HelloShop.ProductService/Constants/DbConstants.cs +++ b/src/HelloShop.ProductService/Constants/DbConstants.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ProductService.Constants; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ProductService.Constants; public static class DbConstants { diff --git a/src/HelloShop.ProductService/Controllers/BrandsController.cs b/src/HelloShop.ProductService/Controllers/BrandsController.cs index bd76dde..dc60411 100644 --- a/src/HelloShop.ProductService/Controllers/BrandsController.cs +++ b/src/HelloShop.ProductService/Controllers/BrandsController.cs @@ -1,13 +1,16 @@ -using AutoMapper; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using AutoMapper; using HelloShop.ProductService.Entities.Products; using HelloShop.ProductService.EntityFrameworks; using HelloShop.ProductService.Models.Products; +using HelloShop.ProductService.PermissionProviders; +using HelloShop.ServiceDefaults.Extensions; using HelloShop.ServiceDefaults.Models.Paging; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; -using HelloShop.ServiceDefaults.Extensions; -using Microsoft.AspNetCore.Authorization; -using HelloShop.ProductService.PermissionProviders; namespace HelloShop.ProductService; [Route("api/[controller]")] diff --git a/src/HelloShop.ProductService/Controllers/MockProductsController.cs b/src/HelloShop.ProductService/Controllers/MockProductsController.cs new file mode 100644 index 0000000..0538655 --- /dev/null +++ b/src/HelloShop.ProductService/Controllers/MockProductsController.cs @@ -0,0 +1,93 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using AutoMapper; +using HelloShop.ProductService.Entities.Products; +using HelloShop.ProductService.Models.Products; +using HelloShop.ProductService.PermissionProviders; +using HelloShop.ProductService.Services; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace HelloShop.ProductService.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class MockProductsController(IProductService productService, IMapper mapper) : ControllerBase + { + [HttpGet] + [Authorize(CatalogPermissions.Products.Default)] + public async Task>> GetProducts() + { + List products = await productService.GetAllAsync(); + + return mapper.Map>(products); + } + + [HttpGet("{id}")] + [Authorize(CatalogPermissions.Products.Details)] + public async Task> GetProduct(int id) + { + Product? entity = await productService.FindAsync(id); + + if (entity is null) + { + return NotFound(); + } + + return mapper.Map(entity); + } + + [HttpPost] + [Authorize(CatalogPermissions.Products.Create)] + public async Task> PostProduct(ProductCreateRequest model) + { + Product entity = mapper.Map(model); + + await productService.CreateAsync(entity); + + ProductDetailsResponse result = mapper.Map(entity); + + return CreatedAtAction(nameof(GetProduct), new { id = entity.Id }, result); + } + + [HttpPut("{id}")] + [Authorize(CatalogPermissions.Products.Update)] + public async Task PutProduct(int id, ProductUpdateRequest model) + { + if (id != model.Id) + { + return BadRequest(); + } + + Product? entity = await productService.FindAsync(id); + + if (entity is null) + { + return NotFound(); + } + + mapper.Map(model, entity); + + await productService.UpdateAsyc(entity); + + return NoContent(); + } + + [HttpDelete("{id}")] + [Authorize(CatalogPermissions.Products.Delete)] + public async Task DeleteProduct(int id) + { + Product? entity = await productService.FindAsync(id); + + if (entity is null) + { + return NotFound(); + } + + await productService.DeleteAsync(entity); + + return NoContent(); + } + } +} diff --git a/src/HelloShop.ProductService/Controllers/ProductsController.cs b/src/HelloShop.ProductService/Controllers/ProductsController.cs index 997bbc8..9eb2f5c 100644 --- a/src/HelloShop.ProductService/Controllers/ProductsController.cs +++ b/src/HelloShop.ProductService/Controllers/ProductsController.cs @@ -1,118 +1,121 @@ -using HelloShop.ProductService.Entities.Products; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using AutoMapper; +using HelloShop.ProductService.Entities.Products; using HelloShop.ProductService.EntityFrameworks; using HelloShop.ProductService.Models.Products; -using HelloShop.ServiceDefaults.Models.Paging; -using Microsoft.AspNetCore.Mvc; -using HelloShop.ServiceDefaults.Extensions; -using AutoMapper; -using Microsoft.EntityFrameworkCore; -using Microsoft.AspNetCore.Authorization; using HelloShop.ProductService.PermissionProviders; +using HelloShop.ServiceDefaults.Extensions; +using HelloShop.ServiceDefaults.Models.Paging; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; namespace HelloShop.ProductService; - [Route("api/[controller]")] - [ApiController] - public class ProductsController(ProductServiceDbContext dbContext, IMapper mapper) : ControllerBase - { - [HttpGet] - [Authorize(CatalogPermissions.Products.Default)] - public async Task>> GetProducts([FromQuery] KeywordSearchRequest model) - { - IQueryable query = dbContext.Set().Include(x => x.Brand).AsNoTracking(); +[Route("api/[controller]")] +[ApiController] +public class ProductsController(ProductServiceDbContext dbContext, IMapper mapper) : ControllerBase +{ + [HttpGet] + [Authorize(CatalogPermissions.Products.Default)] + public async Task>> GetProducts([FromQuery] KeywordSearchRequest model) + { + IQueryable query = dbContext.Set().Include(x => x.Brand).AsNoTracking(); - query = query.WhereIf(model.Keyword is not null, x => model.Keyword != null && x.Name.Contains(model.Keyword)); + query = query.WhereIf(model.Keyword is not null, x => model.Keyword != null && x.Name.Contains(model.Keyword)); - var pagedProducts = query.SortAndPageBy(model); + var pagedProducts = query.SortAndPageBy(model); - return new PagedResponse(mapper.Map>(await pagedProducts.ToListAsync()), await query.CountAsync()); - } + return new PagedResponse(mapper.Map>(await pagedProducts.ToListAsync()), await query.CountAsync()); + } - [HttpGet("{id}")] - [Authorize(CatalogPermissions.Products.Details)] - public async Task> GetProduct(int id) - { - Product? entity = await dbContext.Set().FindAsync(id); + [HttpGet("{id}")] + [Authorize(CatalogPermissions.Products.Details)] + public async Task> GetProduct(int id) + { + Product? entity = await dbContext.Set().FindAsync(id); - if (entity is null) - { - return NotFound(); - } + if (entity is null) + { + return NotFound(); + } - await dbContext.Entry(entity).Reference(e => e.Brand).LoadAsync(); + await dbContext.Entry(entity).Reference(e => e.Brand).LoadAsync(); - return mapper.Map(entity); - } + return mapper.Map(entity); + } - [HttpPost] - [Authorize(CatalogPermissions.Products.Create)] - public async Task> PostProduct(ProductCreateRequest model) - { - Product entity = mapper.Map(model); + [HttpPost] + [Authorize(CatalogPermissions.Products.Create)] + public async Task> PostProduct(ProductCreateRequest model) + { + Product entity = mapper.Map(model); - await dbContext.AddAsync(entity); + await dbContext.AddAsync(entity); - await dbContext.SaveChangesAsync(); + await dbContext.SaveChangesAsync(); - ProductDetailsResponse result = mapper.Map(entity); + ProductDetailsResponse result = mapper.Map(entity); - return CreatedAtAction(nameof(GetProduct), new { id = entity.Id }, result); - } + return CreatedAtAction(nameof(GetProduct), new { id = entity.Id }, result); + } - [HttpPut("{id}")] - [Authorize(CatalogPermissions.Products.Update)] - public async Task PutProduct(int id, ProductUpdateRequest model) - { - if (id != model.Id) - { - return BadRequest(); - } + [HttpPut("{id}")] + [Authorize(CatalogPermissions.Products.Update)] + public async Task PutProduct(int id, ProductUpdateRequest model) + { + if (id != model.Id) + { + return BadRequest(); + } - Product entity = mapper.Map(model); + Product entity = mapper.Map(model); - dbContext.Entry(entity).State = EntityState.Modified; + dbContext.Entry(entity).State = EntityState.Modified; - try - { - await dbContext.SaveChangesAsync(); - } - catch (DbUpdateConcurrencyException) - { - if (!dbContext.Set().Any(e => e.Id == id)) - { - return NotFound(); - } - else - { - throw; - } - } - return NoContent(); - } + try + { + await dbContext.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!dbContext.Set().Any(e => e.Id == id)) + { + return NotFound(); + } + else + { + throw; + } + } + return NoContent(); + } - [HttpDelete("{id}")] - [Authorize(CatalogPermissions.Products.Delete)] - public async Task DeleteProduct(int id) - { - Product? entity = await dbContext.Set().FindAsync(id); + [HttpDelete("{id}")] + [Authorize(CatalogPermissions.Products.Delete)] + public async Task DeleteProduct(int id) + { + Product? entity = await dbContext.Set().FindAsync(id); - if (entity is null) - { - return NotFound(); - } + if (entity is null) + { + return NotFound(); + } - dbContext.Remove(entity); + dbContext.Remove(entity); - await dbContext.SaveChangesAsync(); - return NoContent(); - } + await dbContext.SaveChangesAsync(); + return NoContent(); + } - [HttpDelete] - [Authorize(CatalogPermissions.Products.Delete)] - public async Task DeleteProducts([FromQuery] IEnumerable ids) - { - await dbContext.Set().Where(e => ids.Contains(e.Id)).ExecuteDeleteAsync(); + [HttpDelete] + [Authorize(CatalogPermissions.Products.Delete)] + public async Task DeleteProducts([FromQuery] IEnumerable ids) + { + await dbContext.Set().Where(e => ids.Contains(e.Id)).ExecuteDeleteAsync(); - return NoContent(); - } - } \ No newline at end of file + return NoContent(); + } +} \ No newline at end of file diff --git a/src/HelloShop.ProductService/DataSeeding/ProductDataSeedingProvider.cs b/src/HelloShop.ProductService/DataSeeding/ProductDataSeedingProvider.cs index aaddc97..66aca16 100644 --- a/src/HelloShop.ProductService/DataSeeding/ProductDataSeedingProvider.cs +++ b/src/HelloShop.ProductService/DataSeeding/ProductDataSeedingProvider.cs @@ -1,4 +1,7 @@ -using HelloShop.ProductService.Entities.Products; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ProductService.Entities.Products; using HelloShop.ProductService.EntityFrameworks; using HelloShop.ServiceDefaults.Infrastructure; @@ -84,7 +87,7 @@ namespace HelloShop.ProductService.DataSeeding foreach (var product in productList) { product.Brand = brand; - await dbContext.AddAsync(product); + await dbContext.AddAsync(product); } } diff --git a/src/HelloShop.ProductService/Entities/Products/Brand.cs b/src/HelloShop.ProductService/Entities/Products/Brand.cs index e89e6fa..143f79a 100644 --- a/src/HelloShop.ProductService/Entities/Products/Brand.cs +++ b/src/HelloShop.ProductService/Entities/Products/Brand.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ProductService.Entities.Products +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ProductService.Entities.Products { public class Brand { diff --git a/src/HelloShop.ProductService/Entities/Products/Product.cs b/src/HelloShop.ProductService/Entities/Products/Product.cs index f9e8759..e9847c9 100644 --- a/src/HelloShop.ProductService/Entities/Products/Product.cs +++ b/src/HelloShop.ProductService/Entities/Products/Product.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ProductService.Entities.Products +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ProductService.Entities.Products { public class Product { diff --git a/src/HelloShop.ProductService/EntityFrameworks/EntityConfigurations/Products/BrandEntityTypeConfiguration.cs b/src/HelloShop.ProductService/EntityFrameworks/EntityConfigurations/Products/BrandEntityTypeConfiguration.cs index 084479f..f8177b7 100644 --- a/src/HelloShop.ProductService/EntityFrameworks/EntityConfigurations/Products/BrandEntityTypeConfiguration.cs +++ b/src/HelloShop.ProductService/EntityFrameworks/EntityConfigurations/Products/BrandEntityTypeConfiguration.cs @@ -1,14 +1,17 @@ -using HelloShop.ProductService.Entities.Products; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ProductService.Entities.Products; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace HelloShop.ProductService.EntityFrameworks.EntityConfigurations.Products; - public class BrandEntityTypeConfiguration : IEntityTypeConfiguration +public class BrandEntityTypeConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) { - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable("Brands"); - builder.Property(x => x.Name).HasMaxLength(32); - } - } \ No newline at end of file + builder.ToTable("Brands"); + builder.Property(x => x.Name).HasMaxLength(32); + } +} \ No newline at end of file diff --git a/src/HelloShop.ProductService/EntityFrameworks/EntityConfigurations/Products/ProductEntityTypeConfiguration.cs b/src/HelloShop.ProductService/EntityFrameworks/EntityConfigurations/Products/ProductEntityTypeConfiguration.cs index 98f6036..d3ddb61 100644 --- a/src/HelloShop.ProductService/EntityFrameworks/EntityConfigurations/Products/ProductEntityTypeConfiguration.cs +++ b/src/HelloShop.ProductService/EntityFrameworks/EntityConfigurations/Products/ProductEntityTypeConfiguration.cs @@ -1,19 +1,22 @@ -using HelloShop.ProductService.Entities.Products; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ProductService.Entities.Products; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace HelloShop.ProductService.EntityFrameworks.EntityConfigurations.Products; - public class ProductEntityTypeConfiguration : IEntityTypeConfiguration - { - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable("Products"); +public class ProductEntityTypeConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable("Products"); - builder.Property(x => x.Name).HasMaxLength(32); + builder.Property(x => x.Name).HasMaxLength(32); - builder.Property(x => x.ImageUrl).HasMaxLength(256); + builder.Property(x => x.ImageUrl).HasMaxLength(256); - builder.HasOne(x => x.Brand).WithMany(); - } - } + builder.HasOne(x => x.Brand).WithMany(); + } +} diff --git a/src/HelloShop.ProductService/EntityFrameworks/Migrations/20240419145737_InitialCreate.cs b/src/HelloShop.ProductService/EntityFrameworks/Migrations/20240419145737_InitialCreate.cs index 5a8770d..f7abca2 100644 --- a/src/HelloShop.ProductService/EntityFrameworks/Migrations/20240419145737_InitialCreate.cs +++ b/src/HelloShop.ProductService/EntityFrameworks/Migrations/20240419145737_InitialCreate.cs @@ -1,4 +1,6 @@ -using System; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; diff --git a/src/HelloShop.ProductService/EntityFrameworks/ProductServiceDbContext.cs b/src/HelloShop.ProductService/EntityFrameworks/ProductServiceDbContext.cs index 78eff35..9a05e06 100644 --- a/src/HelloShop.ProductService/EntityFrameworks/ProductServiceDbContext.cs +++ b/src/HelloShop.ProductService/EntityFrameworks/ProductServiceDbContext.cs @@ -1,14 +1,17 @@ -using Microsoft.EntityFrameworkCore; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.EntityFrameworkCore; using System.Reflection; namespace HelloShop.ProductService.EntityFrameworks; - public class ProductServiceDbContext(DbContextOptions options) : DbContext(options) - { - protected override void OnModelCreating(ModelBuilder builder) - { - base.OnModelCreating(builder); +public class ProductServiceDbContext(DbContextOptions options) : DbContext(options) +{ + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); - builder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); - } - } + builder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); + } +} diff --git a/src/HelloShop.ProductService/HelloShop.ProductService.csproj b/src/HelloShop.ProductService/HelloShop.ProductService.csproj index 45f5f5a..7a3fbcb 100644 --- a/src/HelloShop.ProductService/HelloShop.ProductService.csproj +++ b/src/HelloShop.ProductService/HelloShop.ProductService.csproj @@ -1,24 +1,18 @@ - - net9.0 - enable - enable - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - - - - - + + net8.0 + enable + enable + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + \ No newline at end of file diff --git a/src/HelloShop.ProductService/Models/Products/BrandCreateRequest.cs b/src/HelloShop.ProductService/Models/Products/BrandCreateRequest.cs index 464c7e4..110bc45 100644 --- a/src/HelloShop.ProductService/Models/Products/BrandCreateRequest.cs +++ b/src/HelloShop.ProductService/Models/Products/BrandCreateRequest.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ProductService.Models.Products; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ProductService.Models.Products; public class BrandCreateRequest { diff --git a/src/HelloShop.ProductService/Models/Products/BrandDetailsResponse.cs b/src/HelloShop.ProductService/Models/Products/BrandDetailsResponse.cs index 96b16fa..60aac14 100644 --- a/src/HelloShop.ProductService/Models/Products/BrandDetailsResponse.cs +++ b/src/HelloShop.ProductService/Models/Products/BrandDetailsResponse.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ProductService.Models.Products; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ProductService.Models.Products; public class BrandDetailsResponse { diff --git a/src/HelloShop.ProductService/Models/Products/BrandListItem.cs b/src/HelloShop.ProductService/Models/Products/BrandListItem.cs index 6a84182..6cb0bff 100644 --- a/src/HelloShop.ProductService/Models/Products/BrandListItem.cs +++ b/src/HelloShop.ProductService/Models/Products/BrandListItem.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ProductService.Models.Products; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ProductService.Models.Products; public class BrandListItem { diff --git a/src/HelloShop.ProductService/Models/Products/BrandUpdateRequest.cs b/src/HelloShop.ProductService/Models/Products/BrandUpdateRequest.cs index 1ebab26..1b1cc28 100644 --- a/src/HelloShop.ProductService/Models/Products/BrandUpdateRequest.cs +++ b/src/HelloShop.ProductService/Models/Products/BrandUpdateRequest.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ProductService.Models.Products; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ProductService.Models.Products; public class BrandUpdateRequest { diff --git a/src/HelloShop.ProductService/Models/Products/ProductCreateRequest.cs b/src/HelloShop.ProductService/Models/Products/ProductCreateRequest.cs index 68160b5..62d6c2f 100644 --- a/src/HelloShop.ProductService/Models/Products/ProductCreateRequest.cs +++ b/src/HelloShop.ProductService/Models/Products/ProductCreateRequest.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ProductService.Models.Products +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ProductService.Models.Products { public class ProductCreateRequest { diff --git a/src/HelloShop.ProductService/Models/Products/ProductDetailsResponse.cs b/src/HelloShop.ProductService/Models/Products/ProductDetailsResponse.cs index 4e5a7c5..1faf8a9 100644 --- a/src/HelloShop.ProductService/Models/Products/ProductDetailsResponse.cs +++ b/src/HelloShop.ProductService/Models/Products/ProductDetailsResponse.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ProductService.Models.Products; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ProductService.Models.Products; public class ProductDetailsResponse { public int Id { get; init; } diff --git a/src/HelloShop.ProductService/Models/Products/ProductListItem.cs b/src/HelloShop.ProductService/Models/Products/ProductListItem.cs index b7a55a4..6835d12 100644 --- a/src/HelloShop.ProductService/Models/Products/ProductListItem.cs +++ b/src/HelloShop.ProductService/Models/Products/ProductListItem.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ProductService.Models.Products; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ProductService.Models.Products; public class ProductListItem { diff --git a/src/HelloShop.ProductService/Models/Products/ProductUpdateRequest.cs b/src/HelloShop.ProductService/Models/Products/ProductUpdateRequest.cs index 551ec68..688589d 100644 --- a/src/HelloShop.ProductService/Models/Products/ProductUpdateRequest.cs +++ b/src/HelloShop.ProductService/Models/Products/ProductUpdateRequest.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ProductService.Models.Products +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ProductService.Models.Products { public class ProductUpdateRequest { diff --git a/src/HelloShop.ProductService/PermissionProviders/CatalogPermissionDefinitionProvider.cs b/src/HelloShop.ProductService/PermissionProviders/CatalogPermissionDefinitionProvider.cs index a072b14..059c669 100644 --- a/src/HelloShop.ProductService/PermissionProviders/CatalogPermissionDefinitionProvider.cs +++ b/src/HelloShop.ProductService/PermissionProviders/CatalogPermissionDefinitionProvider.cs @@ -1,25 +1,27 @@ -using HelloShop.ServiceDefaults.Permissions; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ServiceDefaults.Permissions; using Microsoft.Extensions.Localization; -using System.Security; namespace HelloShop.ProductService.PermissionProviders; - public class CatalogPermissionDefinitionProvider(IStringLocalizer localizer) : IPermissionDefinitionProvider - { - public void Define(PermissionDefinitionContext context) - { - var identityGroup = context.AddGroup(CatalogPermissions.GroupName, localizer["CatalogManagement"]); +public class CatalogPermissionDefinitionProvider(IStringLocalizer localizer) : IPermissionDefinitionProvider +{ + public void Define(PermissionDefinitionContext context) + { + var identityGroup = context.AddGroup(CatalogPermissions.GroupName, localizer["CatalogManagement"]); - var productsPermission = identityGroup.AddPermission(CatalogPermissions.Products.Default, localizer["ProductManagement"]); - productsPermission.AddChild(CatalogPermissions.Products.Create, localizer["Create"]); - productsPermission.AddChild(CatalogPermissions.Products.Details, localizer["Details"]); - productsPermission.AddChild(CatalogPermissions.Products.Update, localizer["Edit"]); - productsPermission.AddChild(CatalogPermissions.Products.Delete, localizer["Delete"]); + var productsPermission = identityGroup.AddPermission(CatalogPermissions.Products.Default, localizer["ProductManagement"]); + productsPermission.AddChild(CatalogPermissions.Products.Create, localizer["Create"]); + productsPermission.AddChild(CatalogPermissions.Products.Details, localizer["Details"]); + productsPermission.AddChild(CatalogPermissions.Products.Update, localizer["Edit"]); + productsPermission.AddChild(CatalogPermissions.Products.Delete, localizer["Delete"]); - var brandsPermission = identityGroup.AddPermission(CatalogPermissions.Brands.Default, localizer["BrandManagement"]); - brandsPermission.AddChild(CatalogPermissions.Brands.Create, localizer["Create"]); - brandsPermission.AddChild(CatalogPermissions.Brands.Details, localizer["Details"]); - brandsPermission.AddChild(CatalogPermissions.Brands.Update, localizer["Edit"]); - brandsPermission.AddChild(CatalogPermissions.Brands.Delete, localizer["Delete"]); - } - } \ No newline at end of file + var brandsPermission = identityGroup.AddPermission(CatalogPermissions.Brands.Default, localizer["BrandManagement"]); + brandsPermission.AddChild(CatalogPermissions.Brands.Create, localizer["Create"]); + brandsPermission.AddChild(CatalogPermissions.Brands.Details, localizer["Details"]); + brandsPermission.AddChild(CatalogPermissions.Brands.Update, localizer["Edit"]); + brandsPermission.AddChild(CatalogPermissions.Brands.Delete, localizer["Delete"]); + } +} \ No newline at end of file diff --git a/src/HelloShop.ProductService/PermissionProviders/CatalogPermissions.cs b/src/HelloShop.ProductService/PermissionProviders/CatalogPermissions.cs index 1c35d39..a667d2a 100644 --- a/src/HelloShop.ProductService/PermissionProviders/CatalogPermissions.cs +++ b/src/HelloShop.ProductService/PermissionProviders/CatalogPermissions.cs @@ -1,24 +1,27 @@ -namespace HelloShop.ProductService.PermissionProviders; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. - public static class CatalogPermissions - { - public const string GroupName = "Catalog"; +namespace HelloShop.ProductService.PermissionProviders; - public static class Products - { - public const string Default = GroupName + ".Products"; - public const string Details = Default + ".Details"; - public const string Create = Default + ".Create"; - public const string Update = Default + ".Update"; - public const string Delete = Default + ".Delete"; - } +public static class CatalogPermissions +{ + public const string GroupName = "Catalog"; - public static class Brands - { - public const string Default = GroupName + ".Brands"; - public const string Details = Default + ".Details"; - public const string Create = Default + ".Create"; - public const string Update = Default + ".Update"; - public const string Delete = Default + ".Delete"; - } - } \ No newline at end of file + public static class Products + { + public const string Default = GroupName + ".Products"; + public const string Details = Default + ".Details"; + public const string Create = Default + ".Create"; + public const string Update = Default + ".Update"; + public const string Delete = Default + ".Delete"; + } + + public static class Brands + { + public const string Default = GroupName + ".Brands"; + public const string Details = Default + ".Details"; + public const string Create = Default + ".Create"; + public const string Update = Default + ".Update"; + public const string Delete = Default + ".Delete"; + } +} \ No newline at end of file diff --git a/src/HelloShop.ProductService/Program.cs b/src/HelloShop.ProductService/Program.cs index bc5c483..1b4dc3a 100644 --- a/src/HelloShop.ProductService/Program.cs +++ b/src/HelloShop.ProductService/Program.cs @@ -1,7 +1,10 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using HelloShop.ProductService.Constants; using HelloShop.ProductService.EntityFrameworks; -using Microsoft.EntityFrameworkCore; using HelloShop.ServiceDefaults.Extensions; +using Microsoft.EntityFrameworkCore; var builder = WebApplication.CreateBuilder(args); @@ -29,8 +32,6 @@ var app = builder.Build(); app.MapDefaultEndpoints(); -app.UseHttpsRedirection(); - app.UseAuthorization(); app.UseCors(options => options.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); @@ -45,3 +46,8 @@ app.MapGroup("api/Permissions").MapPermissionDefinitions("Permissions"); // End configure extensions request pipeline. app.Run(); + +/// +/// The test project requires a public Program type. +/// +public partial class Program { } \ No newline at end of file diff --git a/src/HelloShop.ProductService/Properties/launchSettings.json b/src/HelloShop.ProductService/Properties/launchSettings.json index 42a8318..cd6c723 100644 --- a/src/HelloShop.ProductService/Properties/launchSettings.json +++ b/src/HelloShop.ProductService/Properties/launchSettings.json @@ -1,20 +1,12 @@ { - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:48824", - "sslPort": 44308 - } - }, + "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { "http": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "http://localhost:5091", + "applicationUrl": "http://localhost:8003", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -24,18 +16,10 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "https://localhost:7046;http://localhost:5091", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", + "applicationUrl": "https://localhost:8103;http://localhost:8003", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } -} +} \ No newline at end of file diff --git a/src/HelloShop.ProductService/Services/IProductService.cs b/src/HelloShop.ProductService/Services/IProductService.cs new file mode 100644 index 0000000..20cf59b --- /dev/null +++ b/src/HelloShop.ProductService/Services/IProductService.cs @@ -0,0 +1,20 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ProductService.Entities.Products; + +namespace HelloShop.ProductService.Services +{ + public interface IProductService + { + Task> GetAllAsync(CancellationToken cancellationToken = default); + + ValueTask FindAsync(int id, CancellationToken cancellationToken = default); + + Task CreateAsync(Product product, CancellationToken cancellationToken = default); + + Task UpdateAsyc(Product product, CancellationToken cancellationToken = default); + + Task DeleteAsync(Product product, CancellationToken cancellationToken = default); + } +} diff --git a/src/HelloShop.ProductService/Services/ProductService.cs b/src/HelloShop.ProductService/Services/ProductService.cs new file mode 100644 index 0000000..659e9c2 --- /dev/null +++ b/src/HelloShop.ProductService/Services/ProductService.cs @@ -0,0 +1,39 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ProductService.Entities.Products; + +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ProductService.EntityFrameworks; +using Microsoft.EntityFrameworkCore; + +namespace HelloShop.ProductService.Services +{ + public class ProductService(ProductServiceDbContext dbContext) : IProductService + { + public async Task CreateAsync(Product product, CancellationToken cancellationToken = default) + { + await dbContext.AddAsync(product, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + } + + public async Task DeleteAsync(Product product, CancellationToken cancellationToken = default) + { + dbContext.Remove(product); + await dbContext.SaveChangesAsync(cancellationToken); + } + + public async ValueTask FindAsync(int id, CancellationToken cancellationToken = default) => await dbContext.FindAsync(id, cancellationToken); + + public async Task> GetAllAsync(CancellationToken cancellationToken = default) => await dbContext.Set().ToListAsync(cancellationToken); + + public async Task UpdateAsyc(Product product, CancellationToken cancellationToken = default) + { + dbContext.Update(product); + + await dbContext.SaveChangesAsync(cancellationToken); + } + } +} diff --git a/src/HelloShop.ProductService/Validations/Products/BrandCreateRequestValidator.cs b/src/HelloShop.ProductService/Validations/Products/BrandCreateRequestValidator.cs index 8fdd0c3..fbaf2f3 100644 --- a/src/HelloShop.ProductService/Validations/Products/BrandCreateRequestValidator.cs +++ b/src/HelloShop.ProductService/Validations/Products/BrandCreateRequestValidator.cs @@ -1,4 +1,7 @@ -using FluentValidation; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using FluentValidation; using HelloShop.ProductService.Models.Products; namespace HelloShop.ProductService.Validations.Products diff --git a/src/HelloShop.ProductService/Validations/Products/BrandUpdateRequestValidator.cs b/src/HelloShop.ProductService/Validations/Products/BrandUpdateRequestValidator.cs index 7b0ba35..2330563 100644 --- a/src/HelloShop.ProductService/Validations/Products/BrandUpdateRequestValidator.cs +++ b/src/HelloShop.ProductService/Validations/Products/BrandUpdateRequestValidator.cs @@ -1,4 +1,7 @@ -using FluentValidation; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using FluentValidation; using HelloShop.ProductService.Models.Products; namespace HelloShop.ProductService.Validations.Products diff --git a/src/HelloShop.ProductService/Validations/Products/ProductCreateRequestValidator.cs b/src/HelloShop.ProductService/Validations/Products/ProductCreateRequestValidator.cs index f6829ad..5ab3d48 100644 --- a/src/HelloShop.ProductService/Validations/Products/ProductCreateRequestValidator.cs +++ b/src/HelloShop.ProductService/Validations/Products/ProductCreateRequestValidator.cs @@ -4,7 +4,7 @@ using FluentValidation; using HelloShop.ProductService.Models.Products; -namespace HelloWorld.ProductService.Validations.Products +namespace HelloShop.ProductService.Validations.Products { public class ProductCreateRequestValidator : AbstractValidator { diff --git a/src/HelloShop.ProductService/Validations/Products/ProductUpdateRequestValidator.cs b/src/HelloShop.ProductService/Validations/Products/ProductUpdateRequestValidator.cs index 4dfa1dc..c3d828d 100644 --- a/src/HelloShop.ProductService/Validations/Products/ProductUpdateRequestValidator.cs +++ b/src/HelloShop.ProductService/Validations/Products/ProductUpdateRequestValidator.cs @@ -4,7 +4,7 @@ using FluentValidation; using HelloShop.ProductService.Models.Products; -namespace HelloWorld.ProductService.Validations.Products +namespace HelloShop.ProductService.Validations.Products { public class ProductUpdateRequestValidator : AbstractValidator { diff --git a/src/HelloShop.ProductService/WeatherForecast.cs b/src/HelloShop.ProductService/WeatherForecast.cs index e52f88c..b2a2d04 100644 --- a/src/HelloShop.ProductService/WeatherForecast.cs +++ b/src/HelloShop.ProductService/WeatherForecast.cs @@ -1,3 +1,6 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + namespace HelloShop.ProductService; public class WeatherForecast diff --git a/src/HelloShop.ServiceDefaults/Authorization/CustomAuthorizationPolicyProvider.cs b/src/HelloShop.ServiceDefaults/Authorization/CustomAuthorizationPolicyProvider.cs index 846fba4..cc4c250 100644 --- a/src/HelloShop.ServiceDefaults/Authorization/CustomAuthorizationPolicyProvider.cs +++ b/src/HelloShop.ServiceDefaults/Authorization/CustomAuthorizationPolicyProvider.cs @@ -1,4 +1,7 @@ -using HelloShop.ServiceDefaults.Permissions; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ServiceDefaults.Permissions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization.Infrastructure; using Microsoft.Extensions.Options; diff --git a/src/HelloShop.ServiceDefaults/Authorization/FakePermissionChecker.cs b/src/HelloShop.ServiceDefaults/Authorization/FakePermissionChecker.cs new file mode 100644 index 0000000..114db94 --- /dev/null +++ b/src/HelloShop.ServiceDefaults/Authorization/FakePermissionChecker.cs @@ -0,0 +1,13 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Caching.Distributed; + +namespace HelloShop.ServiceDefaults.Authorization +{ + public class FakePermissionChecker(IHttpContextAccessor httpContextAccessor, IDistributedCache distributedCache) : PermissionChecker(httpContextAccessor, distributedCache) + { + public override Task IsGrantedAsync(int roleId, string permissionName, string? resourceType = null, string? resourceId = null) => Task.FromResult(true); + } +} \ No newline at end of file diff --git a/src/HelloShop.ServiceDefaults/Authorization/IAuthorizationResource.cs b/src/HelloShop.ServiceDefaults/Authorization/IAuthorizationResource.cs index 02804b3..8a747b3 100644 --- a/src/HelloShop.ServiceDefaults/Authorization/IAuthorizationResource.cs +++ b/src/HelloShop.ServiceDefaults/Authorization/IAuthorizationResource.cs @@ -1,7 +1,7 @@ -using HelloShop.ServiceDefaults.Constants; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using System.Reflection.Metadata.Ecma335; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ServiceDefaults.Constants; namespace HelloShop.ServiceDefaults.Authorization; diff --git a/src/HelloShop.ServiceDefaults/Authorization/IPermissionChecker.cs b/src/HelloShop.ServiceDefaults/Authorization/IPermissionChecker.cs index 1c375b7..36d0e22 100644 --- a/src/HelloShop.ServiceDefaults/Authorization/IPermissionChecker.cs +++ b/src/HelloShop.ServiceDefaults/Authorization/IPermissionChecker.cs @@ -1,4 +1,7 @@ -using System.Security.Claims; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using System.Security.Claims; namespace HelloShop.ServiceDefaults.Authorization; diff --git a/src/HelloShop.ServiceDefaults/Authorization/PermissionChecker.cs b/src/HelloShop.ServiceDefaults/Authorization/PermissionChecker.cs index 54bd9d6..b22f597 100644 --- a/src/HelloShop.ServiceDefaults/Authorization/PermissionChecker.cs +++ b/src/HelloShop.ServiceDefaults/Authorization/PermissionChecker.cs @@ -1,4 +1,7 @@ -using HelloShop.ServiceDefaults.Constants; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ServiceDefaults.Constants; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Caching.Distributed; using System.Security.Claims; diff --git a/src/HelloShop.ServiceDefaults/Authorization/PermissionGrantCacheItem.cs b/src/HelloShop.ServiceDefaults/Authorization/PermissionGrantCacheItem.cs index 36af03a..2406602 100644 --- a/src/HelloShop.ServiceDefaults/Authorization/PermissionGrantCacheItem.cs +++ b/src/HelloShop.ServiceDefaults/Authorization/PermissionGrantCacheItem.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Authorization; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Authorization; public class PermissionGrantCacheItem(bool isGranted = false) { diff --git a/src/HelloShop.ServiceDefaults/Authorization/PermissionRequirementHandler.cs b/src/HelloShop.ServiceDefaults/Authorization/PermissionRequirementHandler.cs index 565d56b..3fee2ba 100644 --- a/src/HelloShop.ServiceDefaults/Authorization/PermissionRequirementHandler.cs +++ b/src/HelloShop.ServiceDefaults/Authorization/PermissionRequirementHandler.cs @@ -1,4 +1,7 @@ -using Microsoft.AspNetCore.Authorization; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization.Infrastructure; namespace HelloShop.ServiceDefaults.Authorization; @@ -9,7 +12,7 @@ public class PermissionRequirementHandler(IPermissionChecker permissionChecker) { if (context.Resource is IAuthorizationResource resource) { - if (await permissionChecker.IsGrantedAsync(context.User,requirement.Name, resource.ResourceType, resource.ResourceId)) + if (await permissionChecker.IsGrantedAsync(context.User, requirement.Name, resource.ResourceType, resource.ResourceId)) { context.Succeed(requirement); } @@ -21,7 +24,7 @@ public class PermissionRequirementHandler(IPermissionChecker permissionChecker) return; } - if(await permissionChecker.IsGrantedAsync(context.User,requirement.Name)) + if (await permissionChecker.IsGrantedAsync(context.User, requirement.Name)) { context.Succeed(requirement); return; diff --git a/src/HelloShop.ServiceDefaults/Authorization/RemotePermissionChecker.cs b/src/HelloShop.ServiceDefaults/Authorization/RemotePermissionChecker.cs index 2093a93..e0e0f21 100644 --- a/src/HelloShop.ServiceDefaults/Authorization/RemotePermissionChecker.cs +++ b/src/HelloShop.ServiceDefaults/Authorization/RemotePermissionChecker.cs @@ -1,11 +1,11 @@ - +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Caching.Distributed; -using Microsoft.Extensions.Options; using System.Net.Http.Headers; -using System.Net.Http.Json; namespace HelloShop.ServiceDefaults.Authorization; @@ -23,6 +23,7 @@ public class RemotePermissionChecker(IHttpContextAccessor httpContextAccessor, I Dictionary parameters = new() { + { nameof(roleId), roleId.ToString() }, { nameof(permissionName), permissionName }, { nameof(resourceType) , resourceType }, { nameof(resourceId), resourceId } diff --git a/src/HelloShop.ServiceDefaults/Authorization/ResourceInfo.cs b/src/HelloShop.ServiceDefaults/Authorization/ResourceInfo.cs index 88b2e2e..8cba01b 100644 --- a/src/HelloShop.ServiceDefaults/Authorization/ResourceInfo.cs +++ b/src/HelloShop.ServiceDefaults/Authorization/ResourceInfo.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Authorization; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Authorization; public record struct ResourceInfo(string ResourceType, string ResourceId) : IAuthorizationResource { diff --git a/src/HelloShop.ServiceDefaults/Constants/CustomClaimTypes.cs b/src/HelloShop.ServiceDefaults/Constants/CustomClaimTypes.cs index 28688f6..4bb6093 100644 --- a/src/HelloShop.ServiceDefaults/Constants/CustomClaimTypes.cs +++ b/src/HelloShop.ServiceDefaults/Constants/CustomClaimTypes.cs @@ -1,6 +1,9 @@ -namespace HelloShop.ServiceDefaults.Constants; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Constants; public static class CustomClaimTypes { - public const string RoleIdentifier = "roleid"; + public const string RoleIdentifier = "roleid"; } diff --git a/src/HelloShop.ServiceDefaults/Constants/EntityConnstants.cs b/src/HelloShop.ServiceDefaults/Constants/EntityConnstants.cs index a830f80..92ef83a 100644 --- a/src/HelloShop.ServiceDefaults/Constants/EntityConnstants.cs +++ b/src/HelloShop.ServiceDefaults/Constants/EntityConnstants.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Constants; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Constants; public static class EntityConnstants { diff --git a/src/HelloShop.ServiceDefaults/Constants/IdentityConstants.cs b/src/HelloShop.ServiceDefaults/Constants/IdentityConstants.cs index 39e281b..e9c81b6 100644 --- a/src/HelloShop.ServiceDefaults/Constants/IdentityConstants.cs +++ b/src/HelloShop.ServiceDefaults/Constants/IdentityConstants.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Constants; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Constants; public static class IdentityConstants { diff --git a/src/HelloShop.ServiceDefaults/Constants/PagingConstants.cs b/src/HelloShop.ServiceDefaults/Constants/PagingConstants.cs index 4f903d5..44c911e 100644 --- a/src/HelloShop.ServiceDefaults/Constants/PagingConstants.cs +++ b/src/HelloShop.ServiceDefaults/Constants/PagingConstants.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Constants; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Constants; public class PagingConstants { diff --git a/src/HelloShop.ServiceDefaults/Extensions.cs b/src/HelloShop.ServiceDefaults/Extensions.cs index 390733f..e4e0520 100644 --- a/src/HelloShop.ServiceDefaults/Extensions.cs +++ b/src/HelloShop.ServiceDefaults/Extensions.cs @@ -1,14 +1,20 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Logging; -using OpenTelemetry.Logs; +using OpenTelemetry; using OpenTelemetry.Metrics; using OpenTelemetry.Trace; namespace Microsoft.Extensions.Hosting; +// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry. +// This project should be referenced by each service project in your solution. +// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults public static class Extensions { public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder) @@ -25,7 +31,7 @@ public static class Extensions http.AddStandardResilienceHandler(); // Turn on service discovery by default - http.UseServiceDiscovery(); + http.AddServiceDiscovery(); }); return builder; @@ -48,12 +54,6 @@ public static class Extensions }) .WithTracing(tracing => { - if (builder.Environment.IsDevelopment()) - { - // We want to view all traces in development - tracing.SetSampler(new AlwaysOnSampler()); - } - tracing.AddAspNetCoreInstrumentation() // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package) //.AddGrpcClientInstrumentation() @@ -71,15 +71,9 @@ public static class Extensions if (useOtlpExporter) { - builder.Services.Configure(logging => logging.AddOtlpExporter()); - builder.Services.ConfigureOpenTelemetryMeterProvider(metrics => metrics.AddOtlpExporter()); - builder.Services.ConfigureOpenTelemetryTracerProvider(tracing => tracing.AddOtlpExporter()); + builder.Services.AddOpenTelemetry().UseOtlpExporter(); } - // Uncomment the following lines to enable the Prometheus exporter (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package) - // builder.Services.AddOpenTelemetry() - // .WithMetrics(metrics => metrics.AddPrometheusExporter()); - // Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package) //if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"])) //{ @@ -101,9 +95,6 @@ public static class Extensions public static WebApplication MapDefaultEndpoints(this WebApplication app) { - // Uncomment the following line to enable the Prometheus endpoint (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package) - // app.MapPrometheusScrapingEndpoint(); - // Adding health checks endpoints to applications in non-development environments has security implications. // See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments. if (app.Environment.IsDevelopment()) @@ -120,4 +111,4 @@ public static class Extensions return app; } -} +} \ No newline at end of file diff --git a/src/HelloShop.ServiceDefaults/Extensions/CustomDistributedCacheExtensions.cs b/src/HelloShop.ServiceDefaults/Extensions/CustomDistributedCacheExtensions.cs index b4a7b7a..520ddab 100644 --- a/src/HelloShop.ServiceDefaults/Extensions/CustomDistributedCacheExtensions.cs +++ b/src/HelloShop.ServiceDefaults/Extensions/CustomDistributedCacheExtensions.cs @@ -1,4 +1,6 @@ -using Microsoft.Extensions.Caching.Distributed; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using System.Text.Json; namespace Microsoft.Extensions.Caching.Distributed; diff --git a/src/HelloShop.ServiceDefaults/Extensions/DataSeedingExtensions.cs b/src/HelloShop.ServiceDefaults/Extensions/DataSeedingExtensions.cs index f927104..cd97ed1 100644 --- a/src/HelloShop.ServiceDefaults/Extensions/DataSeedingExtensions.cs +++ b/src/HelloShop.ServiceDefaults/Extensions/DataSeedingExtensions.cs @@ -1,12 +1,10 @@ -using HelloShop.ServiceDefaults.Infrastructure; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ServiceDefaults.Infrastructure; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace HelloShop.ServiceDefaults.Extensions { @@ -27,7 +25,7 @@ namespace HelloShop.ServiceDefaults.Extensions { using var serviceScope = app.ApplicationServices.CreateScope(); - var dataSeedingProviders = serviceScope.ServiceProvider.GetServices().OrderBy(x=>x.Order); + var dataSeedingProviders = serviceScope.ServiceProvider.GetServices().OrderBy(x => x.Order); foreach (var dataSeedingProvider in dataSeedingProviders) { diff --git a/src/HelloShop.ServiceDefaults/Extensions/LocalizationExtensions.cs b/src/HelloShop.ServiceDefaults/Extensions/LocalizationExtensions.cs index ab37891..ad17fcd 100644 --- a/src/HelloShop.ServiceDefaults/Extensions/LocalizationExtensions.cs +++ b/src/HelloShop.ServiceDefaults/Extensions/LocalizationExtensions.cs @@ -1,4 +1,7 @@ -using FluentValidation; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using FluentValidation; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; @@ -32,17 +35,17 @@ public static class LocalizationExtensions ValidatorOptions.Global.DisplayNameResolver = (type, memberInfo, lambdaExpression) => { string displayName = memberInfo.Name; - + DisplayAttribute? displayAttribute = memberInfo.GetCustomAttribute(true); - + displayName = displayAttribute?.Name ?? displayName; - + DisplayNameAttribute? displayNameAttribute = memberInfo.GetCustomAttribute(true); - + displayName = displayNameAttribute?.DisplayName ?? displayName; - + var localizer = localizerFactory.Create(type); - + return localizer[displayName]; }; diff --git a/src/HelloShop.ServiceDefaults/Extensions/ModelBindingExtensionns.cs b/src/HelloShop.ServiceDefaults/Extensions/ModelBindingExtensionns.cs index 985fb2f..2a9edf9 100644 --- a/src/HelloShop.ServiceDefaults/Extensions/ModelBindingExtensionns.cs +++ b/src/HelloShop.ServiceDefaults/Extensions/ModelBindingExtensionns.cs @@ -1,4 +1,7 @@ -using FluentValidation; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using FluentValidation; using FluentValidation.AspNetCore; using HelloShop.ServiceDefaults.Infrastructure; using Microsoft.Extensions.DependencyInjection; diff --git a/src/HelloShop.ServiceDefaults/Extensions/OpenApiExtensions.cs b/src/HelloShop.ServiceDefaults/Extensions/OpenApiExtensions.cs index 1054ce2..7d5ab3f 100644 --- a/src/HelloShop.ServiceDefaults/Extensions/OpenApiExtensions.cs +++ b/src/HelloShop.ServiceDefaults/Extensions/OpenApiExtensions.cs @@ -9,13 +9,7 @@ using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.Swagger; using Swashbuckle.AspNetCore.SwaggerGen; using Swashbuckle.AspNetCore.SwaggerUI; -using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; namespace HelloShop.ServiceDefaults.Extensions { diff --git a/src/HelloShop.ServiceDefaults/Extensions/PermissionExtensions.cs b/src/HelloShop.ServiceDefaults/Extensions/PermissionExtensions.cs index 7d368bc..098d1d1 100644 --- a/src/HelloShop.ServiceDefaults/Extensions/PermissionExtensions.cs +++ b/src/HelloShop.ServiceDefaults/Extensions/PermissionExtensions.cs @@ -1,4 +1,7 @@ -using HelloShop.ServiceDefaults.Authorization; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ServiceDefaults.Authorization; using HelloShop.ServiceDefaults.Permissions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; diff --git a/src/HelloShop.ServiceDefaults/Extensions/QueryableExtensions.cs b/src/HelloShop.ServiceDefaults/Extensions/QueryableExtensions.cs index e0a6cf8..60165f2 100644 --- a/src/HelloShop.ServiceDefaults/Extensions/QueryableExtensions.cs +++ b/src/HelloShop.ServiceDefaults/Extensions/QueryableExtensions.cs @@ -1,4 +1,7 @@ -using HelloShop.ServiceDefaults.Constants; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ServiceDefaults.Constants; using HelloShop.ServiceDefaults.Models.Paging; using System.Linq.Expressions; using System.Reflection; diff --git a/src/HelloShop.ServiceDefaults/Extensions/QueryableOrderByExtensions.cs b/src/HelloShop.ServiceDefaults/Extensions/QueryableOrderByExtensions.cs index 713e3d0..ff6f01a 100644 --- a/src/HelloShop.ServiceDefaults/Extensions/QueryableOrderByExtensions.cs +++ b/src/HelloShop.ServiceDefaults/Extensions/QueryableOrderByExtensions.cs @@ -1,4 +1,7 @@ -using System.Collections.Concurrent; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using System.Collections.Concurrent; using System.Linq.Expressions; namespace HelloShop.ServiceDefaults.Extensions; diff --git a/src/HelloShop.ServiceDefaults/HelloShop.ServiceDefaults.csproj b/src/HelloShop.ServiceDefaults/HelloShop.ServiceDefaults.csproj index ba64b89..45dd05a 100644 --- a/src/HelloShop.ServiceDefaults/HelloShop.ServiceDefaults.csproj +++ b/src/HelloShop.ServiceDefaults/HelloShop.ServiceDefaults.csproj @@ -1,24 +1,24 @@ - - net9.0 - enable - enable - true - - - - - - - - - - - - - - - + + net8.0 + enable + enable + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/HelloShop.ServiceDefaults/Infrastructure/AcceptLanguageHeaderOperationFilter.cs b/src/HelloShop.ServiceDefaults/Infrastructure/AcceptLanguageHeaderOperationFilter.cs index 7138292..74dcb1b 100644 --- a/src/HelloShop.ServiceDefaults/Infrastructure/AcceptLanguageHeaderOperationFilter.cs +++ b/src/HelloShop.ServiceDefaults/Infrastructure/AcceptLanguageHeaderOperationFilter.cs @@ -1,4 +1,7 @@ -using Microsoft.Net.Http.Headers; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.Net.Http.Headers; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; diff --git a/src/HelloShop.ServiceDefaults/Infrastructure/CustomFluentValidationLanguageManager.cs b/src/HelloShop.ServiceDefaults/Infrastructure/CustomFluentValidationLanguageManager.cs index 457f818..8affd90 100644 --- a/src/HelloShop.ServiceDefaults/Infrastructure/CustomFluentValidationLanguageManager.cs +++ b/src/HelloShop.ServiceDefaults/Infrastructure/CustomFluentValidationLanguageManager.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Infrastructure; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Infrastructure; public class CustomFluentValidationLanguageManager : FluentValidation.Resources.LanguageManager { diff --git a/src/HelloShop.ServiceDefaults/Infrastructure/IDataSeedingProvider.cs b/src/HelloShop.ServiceDefaults/Infrastructure/IDataSeedingProvider.cs index 302be74..c9c06f8 100644 --- a/src/HelloShop.ServiceDefaults/Infrastructure/IDataSeedingProvider.cs +++ b/src/HelloShop.ServiceDefaults/Infrastructure/IDataSeedingProvider.cs @@ -1,8 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. namespace HelloShop.ServiceDefaults.Infrastructure { diff --git a/src/HelloShop.ServiceDefaults/Infrastructure/PascalCaseNamingPolicy.cs b/src/HelloShop.ServiceDefaults/Infrastructure/PascalCaseNamingPolicy.cs index 6f0c121..9dfcfee 100644 --- a/src/HelloShop.ServiceDefaults/Infrastructure/PascalCaseNamingPolicy.cs +++ b/src/HelloShop.ServiceDefaults/Infrastructure/PascalCaseNamingPolicy.cs @@ -1,4 +1,7 @@ -using System.Text.Json; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using System.Text.Json; namespace HelloShop.ServiceDefaults; diff --git a/src/HelloShop.ServiceDefaults/Models/Paging/KeywordSearchRequest.cs b/src/HelloShop.ServiceDefaults/Models/Paging/KeywordSearchRequest.cs index 36d2c3b..3a5ba3f 100644 --- a/src/HelloShop.ServiceDefaults/Models/Paging/KeywordSearchRequest.cs +++ b/src/HelloShop.ServiceDefaults/Models/Paging/KeywordSearchRequest.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Models.Paging; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Models.Paging; public class KeywordSearchRequest : PagedAndSortedRequest { diff --git a/src/HelloShop.ServiceDefaults/Models/Paging/PagedAndSortedRequest.cs b/src/HelloShop.ServiceDefaults/Models/Paging/PagedAndSortedRequest.cs index 6afcb2e..9212dcb 100644 --- a/src/HelloShop.ServiceDefaults/Models/Paging/PagedAndSortedRequest.cs +++ b/src/HelloShop.ServiceDefaults/Models/Paging/PagedAndSortedRequest.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Models.Paging; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Models.Paging; public class PagedAndSortedRequest : PagedRequest { diff --git a/src/HelloShop.ServiceDefaults/Models/Paging/PagedRequest.cs b/src/HelloShop.ServiceDefaults/Models/Paging/PagedRequest.cs index 4d8b3bd..b63e9ce 100644 --- a/src/HelloShop.ServiceDefaults/Models/Paging/PagedRequest.cs +++ b/src/HelloShop.ServiceDefaults/Models/Paging/PagedRequest.cs @@ -1,4 +1,7 @@ -using HelloShop.ServiceDefaults.Constants; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ServiceDefaults.Constants; namespace HelloShop.ServiceDefaults.Models.Paging; diff --git a/src/HelloShop.ServiceDefaults/Models/Paging/PagedResponse.cs b/src/HelloShop.ServiceDefaults/Models/Paging/PagedResponse.cs index dc8cc71..40e9dd4 100644 --- a/src/HelloShop.ServiceDefaults/Models/Paging/PagedResponse.cs +++ b/src/HelloShop.ServiceDefaults/Models/Paging/PagedResponse.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Models.Paging; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Models.Paging; public class PagedResponse(IReadOnlyList items, int totalCount) { diff --git a/src/HelloShop.ServiceDefaults/Models/Permissions/PermissionDefinitionResponse.cs b/src/HelloShop.ServiceDefaults/Models/Permissions/PermissionDefinitionResponse.cs index 670b569..4e61376 100644 --- a/src/HelloShop.ServiceDefaults/Models/Permissions/PermissionDefinitionResponse.cs +++ b/src/HelloShop.ServiceDefaults/Models/Permissions/PermissionDefinitionResponse.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Permissions; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Permissions; public class PermissionDefinitionResponse { diff --git a/src/HelloShop.ServiceDefaults/Models/Permissions/PermissionGroupDefinitionResponse.cs b/src/HelloShop.ServiceDefaults/Models/Permissions/PermissionGroupDefinitionResponse.cs index d3a1eb1..f1d782b 100644 --- a/src/HelloShop.ServiceDefaults/Models/Permissions/PermissionGroupDefinitionResponse.cs +++ b/src/HelloShop.ServiceDefaults/Models/Permissions/PermissionGroupDefinitionResponse.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Permissions; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Permissions; public class PermissionGroupDefinitionResponse { diff --git a/src/HelloShop.ServiceDefaults/Permissions/IPermissionDefinitionManager.cs b/src/HelloShop.ServiceDefaults/Permissions/IPermissionDefinitionManager.cs index 90e570d..0cc0e82 100644 --- a/src/HelloShop.ServiceDefaults/Permissions/IPermissionDefinitionManager.cs +++ b/src/HelloShop.ServiceDefaults/Permissions/IPermissionDefinitionManager.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Permissions; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Permissions; public interface IPermissionDefinitionManager { diff --git a/src/HelloShop.ServiceDefaults/Permissions/IPermissionDefinitionProvider.cs b/src/HelloShop.ServiceDefaults/Permissions/IPermissionDefinitionProvider.cs index 335a846..229e212 100644 --- a/src/HelloShop.ServiceDefaults/Permissions/IPermissionDefinitionProvider.cs +++ b/src/HelloShop.ServiceDefaults/Permissions/IPermissionDefinitionProvider.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Permissions; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Permissions; public interface IPermissionDefinitionProvider { diff --git a/src/HelloShop.ServiceDefaults/Permissions/PermissionDefinition.cs b/src/HelloShop.ServiceDefaults/Permissions/PermissionDefinition.cs index 8a0c682..1142879 100644 --- a/src/HelloShop.ServiceDefaults/Permissions/PermissionDefinition.cs +++ b/src/HelloShop.ServiceDefaults/Permissions/PermissionDefinition.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Permissions; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Permissions; public class PermissionDefinition { diff --git a/src/HelloShop.ServiceDefaults/Permissions/PermissionDefinitionContext.cs b/src/HelloShop.ServiceDefaults/Permissions/PermissionDefinitionContext.cs index 6af2fab..3dafecb 100644 --- a/src/HelloShop.ServiceDefaults/Permissions/PermissionDefinitionContext.cs +++ b/src/HelloShop.ServiceDefaults/Permissions/PermissionDefinitionContext.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Permissions; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Permissions; public class PermissionDefinitionContext { diff --git a/src/HelloShop.ServiceDefaults/Permissions/PermissionDefinitionManager.cs b/src/HelloShop.ServiceDefaults/Permissions/PermissionDefinitionManager.cs index 03133d8..20b23b9 100644 --- a/src/HelloShop.ServiceDefaults/Permissions/PermissionDefinitionManager.cs +++ b/src/HelloShop.ServiceDefaults/Permissions/PermissionDefinitionManager.cs @@ -1,4 +1,6 @@ - +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using Microsoft.Extensions.DependencyInjection; namespace HelloShop.ServiceDefaults.Permissions; diff --git a/src/HelloShop.ServiceDefaults/Permissions/PermissionGroupDefinition.cs b/src/HelloShop.ServiceDefaults/Permissions/PermissionGroupDefinition.cs index 047471b..da2a274 100644 --- a/src/HelloShop.ServiceDefaults/Permissions/PermissionGroupDefinition.cs +++ b/src/HelloShop.ServiceDefaults/Permissions/PermissionGroupDefinition.cs @@ -1,4 +1,7 @@ -namespace HelloShop.ServiceDefaults.Permissions; +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +namespace HelloShop.ServiceDefaults.Permissions; public class PermissionGroupDefinition { diff --git a/src/HelloShop.ServiceDefaults/Resources/OpenApi/Custom.css b/src/HelloShop.ServiceDefaults/Resources/OpenApi/Custom.css index e072cb4..3e32e10 100644 --- a/src/HelloShop.ServiceDefaults/Resources/OpenApi/Custom.css +++ b/src/HelloShop.ServiceDefaults/Resources/OpenApi/Custom.css @@ -1,8 +1,14 @@ -.swagger-ui .topbar-wrapper img { - content: url('https://cloud.helloworldnet.com/logo-white.svg'); +.swagger-ui .topbar-wrapper a.link svg { + display: none; } -.swagger-ui .topbar-wrapper .link::after { +.swagger-ui .topbar-wrapper a.link::before { + content: url('https://cloud.helloworldnet.com/logo-white.svg'); + height: 40px; + width: 40px; +} + +.swagger-ui .topbar-wrapper a.link::after { margin-left: 0.5rem; content: "HelloShop"; } @@ -23,9 +29,7 @@ box-sizing: border-box } -.swagger-ui *, -.swagger-ui :after, -.swagger-ui :before { +.swagger-ui *, .swagger-ui :after, .swagger-ui :before { box-sizing: inherit } @@ -65,9 +69,9 @@ align-items: center } -.swagger-ui .opblock-tag:hover { - background: rgba(0, 0, 0, .02) -} + .swagger-ui .opblock-tag:hover { + background: rgba(0, 0, 0, .02) + } .swagger-ui .opblock-tag { font-size: 24px; @@ -76,27 +80,27 @@ color: #3b4151 } -.swagger-ui .opblock-tag.no-desc span { - -webkit-box-flex: 1; - -ms-flex: 1; - flex: 1 -} + .swagger-ui .opblock-tag.no-desc span { + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1 + } -.swagger-ui .opblock-tag svg { - -webkit-transition: all .4s; - transition: all .4s -} + .swagger-ui .opblock-tag svg { + -webkit-transition: all .4s; + transition: all .4s + } -.swagger-ui .opblock-tag small { - font-size: 14px; - font-weight: 400; - padding: 0 10px; - -webkit-box-flex: 1; - -ms-flex: 1; - flex: 1; - font-family: Open Sans, sans-serif; - color: #3b4151 -} + .swagger-ui .opblock-tag small { + font-size: 14px; + font-weight: 400; + padding: 0 10px; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1; + font-family: Open Sans, sans-serif; + color: #3b4151 + } .swagger-ui .parаmeter__type { font-size: 12px; @@ -123,221 +127,217 @@ box-shadow: 0 0 3px rgba(0, 0, 0, .19) } -.swagger-ui .opblock.is-open .opblock-summary { - border-bottom: 1px solid #000 -} + .swagger-ui .opblock.is-open .opblock-summary { + border-bottom: 1px solid #000 + } -.swagger-ui .opblock .opblock-section-header { - padding: 8px 20px; - background: hsla(0, 0%, 100%, .8); - box-shadow: 0 1px 2px rgba(0, 0, 0, .1) -} + .swagger-ui .opblock .opblock-section-header { + padding: 8px 20px; + background: hsla(0, 0%, 100%, .8); + box-shadow: 0 1px 2px rgba(0, 0, 0, .1) + } -.swagger-ui .opblock .opblock-section-header, -.swagger-ui .opblock .opblock-section-header label { - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center -} + .swagger-ui .opblock .opblock-section-header, .swagger-ui .opblock .opblock-section-header label { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center + } -.swagger-ui .opblock .opblock-section-header label { - font-size: 12px; - font-weight: 700; - margin: 0; - font-family: Titillium Web, sans-serif; - color: #3b4151 -} + .swagger-ui .opblock .opblock-section-header label { + font-size: 12px; + font-weight: 700; + margin: 0; + font-family: Titillium Web, sans-serif; + color: #3b4151 + } -.swagger-ui .opblock .opblock-section-header label span { - padding: 0 10px 0 0 -} + .swagger-ui .opblock .opblock-section-header label span { + padding: 0 10px 0 0 + } -.swagger-ui .opblock .opblock-section-header h4 { - font-size: 14px; - margin: 0; - -webkit-box-flex: 1; - -ms-flex: 1; - flex: 1; - font-family: Titillium Web, sans-serif; - color: #3b4151 -} + .swagger-ui .opblock .opblock-section-header h4 { + font-size: 14px; + margin: 0; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1; + font-family: Titillium Web, sans-serif; + color: #3b4151 + } -.swagger-ui .opblock .opblock-summary-method { - font-size: 14px; - font-weight: 700; - min-width: 80px; - padding: 6px 15px; - text-align: center; - border-radius: 3px; - background: #000; - text-shadow: 0 1px 0 rgba(0, 0, 0, .1); - font-family: Titillium Web, sans-serif; - color: #fff -} + .swagger-ui .opblock .opblock-summary-method { + font-size: 14px; + font-weight: 700; + min-width: 80px; + padding: 6px 15px; + text-align: center; + border-radius: 3px; + background: #000; + text-shadow: 0 1px 0 rgba(0, 0, 0, .1); + font-family: Titillium Web, sans-serif; + color: #fff + } -.swagger-ui .opblock .opblock-summary-path, -.swagger-ui .opblock .opblock-summary-path__deprecated { - font-size: 16px; - display: -webkit-box; - display: -ms-flexbox; - display: flex; - padding: 0 10px; - font-family: Source Code Pro, monospace; - font-weight: 600; - color: #3b4151; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center -} + .swagger-ui .opblock .opblock-summary-path, .swagger-ui .opblock .opblock-summary-path__deprecated { + font-size: 16px; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + padding: 0 10px; + font-family: Source Code Pro, monospace; + font-weight: 600; + color: #3b4151; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center + } -.swagger-ui .opblock .opblock-summary-path .view-line-link, -.swagger-ui .opblock .opblock-summary-path__deprecated .view-line-link { - position: relative; - top: 2px; - width: 0; - margin: 0; - cursor: pointer; - -webkit-transition: all .5s; - transition: all .5s -} + .swagger-ui .opblock .opblock-summary-path .view-line-link, .swagger-ui .opblock .opblock-summary-path__deprecated .view-line-link { + position: relative; + top: 2px; + width: 0; + margin: 0; + cursor: pointer; + -webkit-transition: all .5s; + transition: all .5s + } -.swagger-ui .opblock .opblock-summary-path:hover .view-line-link, -.swagger-ui .opblock .opblock-summary-path__deprecated:hover .view-line-link { - width: 18px; - margin: 0 5px -} + .swagger-ui .opblock .opblock-summary-path:hover .view-line-link, .swagger-ui .opblock .opblock-summary-path__deprecated:hover .view-line-link { + width: 18px; + margin: 0 5px + } -.swagger-ui .opblock .opblock-summary-path__deprecated { - text-decoration: line-through -} + .swagger-ui .opblock .opblock-summary-path__deprecated { + text-decoration: line-through + } -.swagger-ui .opblock .opblock-summary-description { - font-size: 13px; - -webkit-box-flex: 1; - -ms-flex: 1; - flex: 1; - font-family: Open Sans, sans-serif; - color: #3b4151 -} + .swagger-ui .opblock .opblock-summary-description { + font-size: 13px; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1; + font-family: Open Sans, sans-serif; + color: #3b4151 + } -.swagger-ui .opblock .opblock-summary { - display: -webkit-box; - display: -ms-flexbox; - display: flex; - padding: 5px; - cursor: pointer; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center -} + .swagger-ui .opblock .opblock-summary { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + padding: 5px; + cursor: pointer; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center + } -.swagger-ui .opblock.opblock-post { - border-color: #49cc90; - background: rgba(73, 204, 144, .1) -} + .swagger-ui .opblock.opblock-post { + border-color: #49cc90; + background: rgba(73, 204, 144, .1) + } -.swagger-ui .opblock.opblock-post .opblock-summary-method { - background: #49cc90 -} + .swagger-ui .opblock.opblock-post .opblock-summary-method { + background: #49cc90 + } -.swagger-ui .opblock.opblock-post .opblock-summary { - border-color: #49cc90 -} + .swagger-ui .opblock.opblock-post .opblock-summary { + border-color: #49cc90 + } -.swagger-ui .opblock.opblock-put { - border-color: #fca130; - background: rgba(252, 161, 48, .1) -} + .swagger-ui .opblock.opblock-put { + border-color: #fca130; + background: rgba(252, 161, 48, .1) + } -.swagger-ui .opblock.opblock-put .opblock-summary-method { - background: #fca130 -} + .swagger-ui .opblock.opblock-put .opblock-summary-method { + background: #fca130 + } -.swagger-ui .opblock.opblock-put .opblock-summary { - border-color: #fca130 -} + .swagger-ui .opblock.opblock-put .opblock-summary { + border-color: #fca130 + } -.swagger-ui .opblock.opblock-delete { - border-color: #f93e3e; - background: rgba(249, 62, 62, .1) -} + .swagger-ui .opblock.opblock-delete { + border-color: #f93e3e; + background: rgba(249, 62, 62, .1) + } -.swagger-ui .opblock.opblock-delete .opblock-summary-method { - background: #f93e3e -} + .swagger-ui .opblock.opblock-delete .opblock-summary-method { + background: #f93e3e + } -.swagger-ui .opblock.opblock-delete .opblock-summary { - border-color: #f93e3e -} + .swagger-ui .opblock.opblock-delete .opblock-summary { + border-color: #f93e3e + } -.swagger-ui .opblock.opblock-get { - border-color: #61affe; - background: rgba(97, 175, 254, .1) -} + .swagger-ui .opblock.opblock-get { + border-color: #61affe; + background: rgba(97, 175, 254, .1) + } -.swagger-ui .opblock.opblock-get .opblock-summary-method { - background: #61affe -} + .swagger-ui .opblock.opblock-get .opblock-summary-method { + background: #61affe + } -.swagger-ui .opblock.opblock-get .opblock-summary { - border-color: #61affe -} + .swagger-ui .opblock.opblock-get .opblock-summary { + border-color: #61affe + } -.swagger-ui .opblock.opblock-patch { - border-color: #50e3c2; - background: rgba(80, 227, 194, .1) -} + .swagger-ui .opblock.opblock-patch { + border-color: #50e3c2; + background: rgba(80, 227, 194, .1) + } -.swagger-ui .opblock.opblock-patch .opblock-summary-method { - background: #50e3c2 -} + .swagger-ui .opblock.opblock-patch .opblock-summary-method { + background: #50e3c2 + } -.swagger-ui .opblock.opblock-patch .opblock-summary { - border-color: #50e3c2 -} + .swagger-ui .opblock.opblock-patch .opblock-summary { + border-color: #50e3c2 + } -.swagger-ui .opblock.opblock-head { - border-color: #9012fe; - background: rgba(144, 18, 254, .1) -} + .swagger-ui .opblock.opblock-head { + border-color: #9012fe; + background: rgba(144, 18, 254, .1) + } -.swagger-ui .opblock.opblock-head .opblock-summary-method { - background: #9012fe -} + .swagger-ui .opblock.opblock-head .opblock-summary-method { + background: #9012fe + } -.swagger-ui .opblock.opblock-head .opblock-summary { - border-color: #9012fe -} + .swagger-ui .opblock.opblock-head .opblock-summary { + border-color: #9012fe + } -.swagger-ui .opblock.opblock-options { - border-color: #0d5aa7; - background: rgba(13, 90, 167, .1) -} + .swagger-ui .opblock.opblock-options { + border-color: #0d5aa7; + background: rgba(13, 90, 167, .1) + } -.swagger-ui .opblock.opblock-options .opblock-summary-method { - background: #0d5aa7 -} + .swagger-ui .opblock.opblock-options .opblock-summary-method { + background: #0d5aa7 + } -.swagger-ui .opblock.opblock-options .opblock-summary { - border-color: #0d5aa7 -} + .swagger-ui .opblock.opblock-options .opblock-summary { + border-color: #0d5aa7 + } -.swagger-ui .opblock.opblock-deprecated { - opacity: .6; - border-color: #ebebeb; - background: hsla(0, 0%, 92%, .1) -} + .swagger-ui .opblock.opblock-deprecated { + opacity: .6; + border-color: #ebebeb; + background: hsla(0, 0%, 92%, .1) + } -.swagger-ui .opblock.opblock-deprecated .opblock-summary-method { - background: #ebebeb -} + .swagger-ui .opblock.opblock-deprecated .opblock-summary-method { + background: #ebebeb + } -.swagger-ui .opblock.opblock-deprecated .opblock-summary { - border-color: #ebebeb -} + .swagger-ui .opblock.opblock-deprecated .opblock-summary { + border-color: #ebebeb + } .swagger-ui .tab { display: -webkit-box; @@ -348,67 +348,62 @@ list-style: none } -.swagger-ui .tab li { - font-size: 12px; - min-width: 100px; - min-width: 90px; - padding: 0; - cursor: pointer; - font-family: Titillium Web, sans-serif; - color: #3b4151 -} + .swagger-ui .tab li { + font-size: 12px; + min-width: 100px; + min-width: 90px; + padding: 0; + cursor: pointer; + font-family: Titillium Web, sans-serif; + color: #3b4151 + } -.swagger-ui .tab li:first-of-type { - position: relative; - padding-left: 0 -} + .swagger-ui .tab li:first-of-type { + position: relative; + padding-left: 0 + } -.swagger-ui .tab li:first-of-type:after { - position: absolute; - top: 0; - right: 6px; - width: 1px; - height: 100%; - content: ""; - background: rgba(0, 0, 0, .2) -} + .swagger-ui .tab li:first-of-type:after { + position: absolute; + top: 0; + right: 6px; + width: 1px; + height: 100%; + content: ""; + background: rgba(0, 0, 0, .2) + } -.swagger-ui .tab li.active { - font-weight: 700 -} + .swagger-ui .tab li.active { + font-weight: 700 + } -.swagger-ui .opblock-description-wrapper, -.swagger-ui .opblock-title_normal { +.swagger-ui .opblock-description-wrapper, .swagger-ui .opblock-title_normal { padding: 15px 20px } -.swagger-ui .opblock-description-wrapper, -.swagger-ui .opblock-description-wrapper h4, -.swagger-ui .opblock-title_normal, -.swagger-ui .opblock-title_normal h4 { - font-size: 12px; - margin: 0 0 5px; - font-family: Open Sans, sans-serif; - color: #3b4151 -} + .swagger-ui .opblock-description-wrapper, .swagger-ui .opblock-description-wrapper h4, .swagger-ui .opblock-title_normal, .swagger-ui .opblock-title_normal h4 { + font-size: 12px; + margin: 0 0 5px; + font-family: Open Sans, sans-serif; + color: #3b4151 + } -.swagger-ui .opblock-description-wrapper p, -.swagger-ui .opblock-title_normal p { - font-size: 14px; - margin: 0; - font-family: Open Sans, sans-serif; - color: #3b4151 -} + .swagger-ui .opblock-description-wrapper p, .swagger-ui .opblock-title_normal p { + font-size: 14px; + margin: 0; + font-family: Open Sans, sans-serif; + color: #3b4151 + } .swagger-ui .execute-wrapper { padding: 20px; text-align: right } -.swagger-ui .execute-wrapper .btn { - width: 100%; - padding: 8px 40px -} + .swagger-ui .execute-wrapper .btn { + width: 100%; + padding: 8px 40px + } .swagger-ui .body-param-options { display: -webkit-box; @@ -420,29 +415,28 @@ flex-direction: column } -.swagger-ui .body-param-options .body-param-edit { - padding: 10px 0 -} + .swagger-ui .body-param-options .body-param-edit { + padding: 10px 0 + } -.swagger-ui .body-param-options label { - padding: 8px 0 -} + .swagger-ui .body-param-options label { + padding: 8px 0 + } -.swagger-ui .body-param-options label select { - margin: 3px 0 0 -} + .swagger-ui .body-param-options label select { + margin: 3px 0 0 + } .swagger-ui .responses-inner { padding: 20px } -.swagger-ui .responses-inner h4, -.swagger-ui .responses-inner h5 { - font-size: 12px; - margin: 10px 0 5px; - font-family: Open Sans, sans-serif; - color: #3b4151 -} + .swagger-ui .responses-inner h4, .swagger-ui .responses-inner h5 { + font-size: 12px; + margin: 10px 0 5px; + font-family: Open Sans, sans-serif; + color: #3b4151 + } .swagger-ui .response-col_status { font-size: 14px; @@ -450,12 +444,12 @@ color: #3b4151 } -.swagger-ui .response-col_status .response-undocumented { - font-size: 11px; - font-family: Source Code Pro, monospace; - font-weight: 600; - color: #999 -} + .swagger-ui .response-col_status .response-undocumented { + font-size: 11px; + font-family: Source Code Pro, monospace; + font-weight: 600; + color: #999 + } .swagger-ui .response-col_description__inner span { font-size: 12px; @@ -470,9 +464,9 @@ color: #fff } -.swagger-ui .response-col_description__inner span p { - margin: 0 -} + .swagger-ui .response-col_description__inner span p { + margin: 0 + } .swagger-ui .opblock-body pre { font-size: 12px; @@ -486,9 +480,9 @@ color: #fff } -.swagger-ui .opblock-body pre span { - color: #fff !important -} + .swagger-ui .opblock-body pre span { + color: #fff !important + } .swagger-ui .scheme-container { margin: 0 0 20px; @@ -497,75 +491,75 @@ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .15) } -.swagger-ui .scheme-container .schemes { - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center -} + .swagger-ui .scheme-container .schemes { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center + } -.swagger-ui .scheme-container .schemes>label { - font-size: 12px; - font-weight: 700; - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -ms-flex-direction: column; - flex-direction: column; - margin: -20px 15px 0 0; - font-family: Titillium Web, sans-serif; - color: #3b4151 -} + .swagger-ui .scheme-container .schemes > label { + font-size: 12px; + font-weight: 700; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; + margin: -20px 15px 0 0; + font-family: Titillium Web, sans-serif; + color: #3b4151 + } -.swagger-ui .scheme-container .schemes>label select { - min-width: 130px; - text-transform: uppercase -} + .swagger-ui .scheme-container .schemes > label select { + min-width: 130px; + text-transform: uppercase + } .swagger-ui .loading-container { padding: 40px 0 60px } -.swagger-ui .loading-container .loading { - position: relative -} + .swagger-ui .loading-container .loading { + position: relative + } -.swagger-ui .loading-container .loading:after { - font-size: 10px; - font-weight: 700; - position: absolute; - top: 50%; - left: 50%; - content: "loading"; - -webkit-transform: translate(-50%, -50%); - transform: translate(-50%, -50%); - text-transform: uppercase; - font-family: Titillium Web, sans-serif; - color: #3b4151 -} + .swagger-ui .loading-container .loading:after { + font-size: 10px; + font-weight: 700; + position: absolute; + top: 50%; + left: 50%; + content: "loading"; + -webkit-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); + text-transform: uppercase; + font-family: Titillium Web, sans-serif; + color: #3b4151 + } -.swagger-ui .loading-container .loading:before { - position: absolute; - top: 50%; - left: 50%; - display: block; - width: 60px; - height: 60px; - margin: -30px; - content: ""; - -webkit-animation: rotation 1s infinite linear, opacity .5s; - animation: rotation 1s infinite linear, opacity .5s; - opacity: 1; - border: 2px solid rgba(85, 85, 85, .1); - border-top-color: rgba(0, 0, 0, .6); - border-radius: 100%; - -webkit-backface-visibility: hidden; - backface-visibility: hidden -} + .swagger-ui .loading-container .loading:before { + position: absolute; + top: 50%; + left: 50%; + display: block; + width: 60px; + height: 60px; + margin: -30px; + content: ""; + -webkit-animation: rotation 1s infinite linear, opacity .5s; + animation: rotation 1s infinite linear, opacity .5s; + opacity: 1; + border: 2px solid rgba(85, 85, 85, .1); + border-top-color: rgba(0, 0, 0, .6); + border-radius: 100%; + -webkit-backface-visibility: hidden; + backface-visibility: hidden + } @-webkit-keyframes rotation { to { @@ -607,43 +601,43 @@ color: #3b4151 } -.swagger-ui .btn[disabled] { - cursor: not-allowed; - opacity: .3 -} + .swagger-ui .btn[disabled] { + cursor: not-allowed; + opacity: .3 + } -.swagger-ui .btn:hover { - box-shadow: 0 0 5px rgba(0, 0, 0, .3) -} + .swagger-ui .btn:hover { + box-shadow: 0 0 5px rgba(0, 0, 0, .3) + } -.swagger-ui .btn.cancel { - border-color: #ff6060; - font-family: Titillium Web, sans-serif; - color: #ff6060 -} + .swagger-ui .btn.cancel { + border-color: #ff6060; + font-family: Titillium Web, sans-serif; + color: #ff6060 + } -.swagger-ui .btn.authorize { - line-height: 1; - display: inline; - color: #49cc90; - border-color: #49cc90 -} + .swagger-ui .btn.authorize { + line-height: 1; + display: inline; + color: #49cc90; + border-color: #49cc90 + } -.swagger-ui .btn.authorize span { - float: left; - padding: 4px 20px 0 0 -} + .swagger-ui .btn.authorize span { + float: left; + padding: 4px 20px 0 0 + } -.swagger-ui .btn.authorize svg { - fill: #49cc90 -} + .swagger-ui .btn.authorize svg { + fill: #49cc90 + } -.swagger-ui .btn.execute { - -webkit-animation: pulse 2s infinite; - animation: pulse 2s infinite; - color: #fff; - border-color: #4990e2 -} + .swagger-ui .btn.execute { + -webkit-animation: pulse 2s infinite; + animation: pulse 2s infinite; + color: #fff; + border-color: #4990e2 + } @-webkit-keyframes pulse { 0% { @@ -688,19 +682,19 @@ padding: 30px } -.swagger-ui .btn-group .btn { - -webkit-box-flex: 1; - -ms-flex: 1; - flex: 1 -} + .swagger-ui .btn-group .btn { + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1 + } -.swagger-ui .btn-group .btn:first-child { - border-radius: 4px 0 0 4px -} + .swagger-ui .btn-group .btn:first-child { + border-radius: 4px 0 0 4px + } -.swagger-ui .btn-group .btn:last-child { - border-radius: 0 4px 4px 0 -} + .swagger-ui .btn-group .btn:last-child { + border-radius: 0 4px 4px 0 + } .swagger-ui .authorization__btn { padding: 0 10px; @@ -708,39 +702,37 @@ background: none } -.swagger-ui .authorization__btn.locked { - opacity: 1 -} + .swagger-ui .authorization__btn.locked { + opacity: 1 + } -.swagger-ui .authorization__btn.unlocked { - opacity: .4 -} + .swagger-ui .authorization__btn.unlocked { + opacity: .4 + } -.swagger-ui .expand-methods, -.swagger-ui .expand-operation { +.swagger-ui .expand-methods, .swagger-ui .expand-operation { border: none; background: none } -.swagger-ui .expand-methods svg, -.swagger-ui .expand-operation svg { - width: 20px; - height: 20px -} + .swagger-ui .expand-methods svg, .swagger-ui .expand-operation svg { + width: 20px; + height: 20px + } .swagger-ui .expand-methods { padding: 0 10px } -.swagger-ui .expand-methods:hover svg { - fill: #444 -} + .swagger-ui .expand-methods:hover svg { + fill: #444 + } -.swagger-ui .expand-methods svg { - -webkit-transition: all .3s; - transition: all .3s; - fill: #777 -} + .swagger-ui .expand-methods svg { + -webkit-transition: all .3s; + transition: all .3s; + fill: #777 + } .swagger-ui button { cursor: pointer; @@ -763,11 +755,11 @@ appearance: none } -.swagger-ui select[multiple] { - margin: 5px 0; - padding: 5px; - background: #f7f7f7 -} + .swagger-ui select[multiple] { + margin: 5px 0; + padding: 5px; + background: #f7f7f7 + } .swagger-ui .opblock-body select { min-width: 230px @@ -781,10 +773,7 @@ color: #3b4151 } -.swagger-ui input[type=email], -.swagger-ui input[type=password], -.swagger-ui input[type=search], -.swagger-ui input[type=text] { +.swagger-ui input[type=email], .swagger-ui input[type=password], .swagger-ui input[type=search], .swagger-ui input[type=text] { min-width: 100px; margin: 5px 0; padding: 8px 10px; @@ -793,67 +782,52 @@ background: #fff } -.swagger-ui input[type=email].invalid, -.swagger-ui input[type=password].invalid, -.swagger-ui input[type=search].invalid, -.swagger-ui input[type=text].invalid { - -webkit-animation: shake .4s 1; - animation: shake .4s 1; - border-color: #f93e3e; - background: #feebeb -} + .swagger-ui input[type=email].invalid, .swagger-ui input[type=password].invalid, .swagger-ui input[type=search].invalid, .swagger-ui input[type=text].invalid { + -webkit-animation: shake .4s 1; + animation: shake .4s 1; + border-color: #f93e3e; + background: #feebeb + } @-webkit-keyframes shake { - - 10%, - 90% { + 10%, 90% { -webkit-transform: translate3d(-1px, 0, 0); transform: translate3d(-1px, 0, 0) } - 20%, - 80% { + 20%, 80% { -webkit-transform: translate3d(2px, 0, 0); transform: translate3d(2px, 0, 0) } - 30%, - 50%, - 70% { + 30%, 50%, 70% { -webkit-transform: translate3d(-4px, 0, 0); transform: translate3d(-4px, 0, 0) } - 40%, - 60% { + 40%, 60% { -webkit-transform: translate3d(4px, 0, 0); transform: translate3d(4px, 0, 0) } } @keyframes shake { - - 10%, - 90% { + 10%, 90% { -webkit-transform: translate3d(-1px, 0, 0); transform: translate3d(-1px, 0, 0) } - 20%, - 80% { + 20%, 80% { -webkit-transform: translate3d(2px, 0, 0); transform: translate3d(2px, 0, 0) } - 30%, - 50%, - 70% { + 30%, 50%, 70% { -webkit-transform: translate3d(-4px, 0, 0); transform: translate3d(-4px, 0, 0) } - 40%, - 60% { + 40%, 60% { -webkit-transform: translate3d(4px, 0, 0); transform: translate3d(4px, 0, 0) } @@ -873,22 +847,22 @@ color: #3b4151 } -.swagger-ui textarea:focus { - border: 2px solid #61affe -} + .swagger-ui textarea:focus { + border: 2px solid #61affe + } -.swagger-ui textarea.curl { - font-size: 12px; - min-height: 100px; - margin: 0; - padding: 10px; - resize: none; - border-radius: 4px; - background: #41444e; - font-family: Source Code Pro, monospace; - font-weight: 600; - color: #fff -} + .swagger-ui textarea.curl { + font-size: 12px; + min-height: 100px; + margin: 0; + padding: 10px; + resize: none; + border-radius: 4px; + background: #41444e; + font-family: Source Code Pro, monospace; + font-weight: 600; + color: #fff + } .swagger-ui .checkbox { padding: 5px 0 10px; @@ -897,50 +871,50 @@ color: #333 } -.swagger-ui .checkbox label { - display: -webkit-box; - display: -ms-flexbox; - display: flex -} + .swagger-ui .checkbox label { + display: -webkit-box; + display: -ms-flexbox; + display: flex + } -.swagger-ui .checkbox p { - font-weight: 400 !important; - font-style: italic; - margin: 0 !important; - font-family: Source Code Pro, monospace; - font-weight: 600; - color: #3b4151 -} + .swagger-ui .checkbox p { + font-weight: 400 !important; + font-style: italic; + margin: 0 !important; + font-family: Source Code Pro, monospace; + font-weight: 600; + color: #3b4151 + } -.swagger-ui .checkbox input[type=checkbox] { - display: none -} + .swagger-ui .checkbox input[type=checkbox] { + display: none + } -.swagger-ui .checkbox input[type=checkbox]+label>.item { - position: relative; - top: 3px; - display: inline-block; - width: 16px; - height: 16px; - margin: 0 8px 0 0; - padding: 5px; - cursor: pointer; - border-radius: 1px; - background: #e8e8e8; - box-shadow: 0 0 0 2px #e8e8e8; - -webkit-box-flex: 0; - -ms-flex: none; - flex: none -} + .swagger-ui .checkbox input[type=checkbox] + label > .item { + position: relative; + top: 3px; + display: inline-block; + width: 16px; + height: 16px; + margin: 0 8px 0 0; + padding: 5px; + cursor: pointer; + border-radius: 1px; + background: #e8e8e8; + box-shadow: 0 0 0 2px #e8e8e8; + -webkit-box-flex: 0; + -ms-flex: none; + flex: none + } -.swagger-ui .checkbox input[type=checkbox]+label>.item:active { - -webkit-transform: scale(.9); - transform: scale(.9) -} + .swagger-ui .checkbox input[type=checkbox] + label > .item:active { + -webkit-transform: scale(.9); + transform: scale(.9) + } -.swagger-ui .checkbox input[type=checkbox]:checked+label>.item { - background: #e8e8e8 url("data:image/svg+xml;charset=utf-8,%3Csvg width='10' height='8' viewBox='3 7 10 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%2341474E' fill-rule='evenodd' d='M6.333 15L3 11.667l1.333-1.334 2 2L11.667 7 13 8.333z'/%3E%3C/svg%3E") 50% no-repeat -} + .swagger-ui .checkbox input[type=checkbox]:checked + label > .item { + background: #e8e8e8 url("data:image/svg+xml;charset=utf-8,%3Csvg width='10' height='8' viewBox='3 7 10 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%2341474E' fill-rule='evenodd' d='M6.333 15L3 11.667l1.333-1.334 2 2L11.667 7 13 8.333z'/%3E%3C/svg%3E") 50% no-repeat + } .swagger-ui .dialog-ux { position: fixed; @@ -951,84 +925,84 @@ left: 0 } -.swagger-ui .dialog-ux .backdrop-ux { - position: fixed; - top: 0; - right: 0; - bottom: 0; - left: 0; - background: rgba(0, 0, 0, .8) -} + .swagger-ui .dialog-ux .backdrop-ux { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + background: rgba(0, 0, 0, .8) + } -.swagger-ui .dialog-ux .modal-ux { - position: absolute; - z-index: 9999; - top: 50%; - left: 50%; - width: 100%; - min-width: 300px; - max-width: 650px; - -webkit-transform: translate(-50%, -50%); - transform: translate(-50%, -50%); - border: 1px solid #ebebeb; - border-radius: 4px; - background: #fff; - box-shadow: 0 10px 30px 0 rgba(0, 0, 0, .2) -} + .swagger-ui .dialog-ux .modal-ux { + position: absolute; + z-index: 9999; + top: 50%; + left: 50%; + width: 100%; + min-width: 300px; + max-width: 650px; + -webkit-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); + border: 1px solid #ebebeb; + border-radius: 4px; + background: #fff; + box-shadow: 0 10px 30px 0 rgba(0, 0, 0, .2) + } -.swagger-ui .dialog-ux .modal-ux-content { - overflow-y: auto; - max-height: 540px; - padding: 20px -} + .swagger-ui .dialog-ux .modal-ux-content { + overflow-y: auto; + max-height: 540px; + padding: 20px + } -.swagger-ui .dialog-ux .modal-ux-content p { - font-size: 12px; - margin: 0 0 5px; - color: #41444e; - font-family: Open Sans, sans-serif; - color: #3b4151 -} + .swagger-ui .dialog-ux .modal-ux-content p { + font-size: 12px; + margin: 0 0 5px; + color: #41444e; + font-family: Open Sans, sans-serif; + color: #3b4151 + } -.swagger-ui .dialog-ux .modal-ux-content h4 { - font-size: 18px; - font-weight: 600; - margin: 15px 0 0; - font-family: Titillium Web, sans-serif; - color: #3b4151 -} + .swagger-ui .dialog-ux .modal-ux-content h4 { + font-size: 18px; + font-weight: 600; + margin: 15px 0 0; + font-family: Titillium Web, sans-serif; + color: #3b4151 + } -.swagger-ui .dialog-ux .modal-ux-header { - display: -webkit-box; - display: -ms-flexbox; - display: flex; - padding: 12px 0; - border-bottom: 1px solid #ebebeb; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center -} + .swagger-ui .dialog-ux .modal-ux-header { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + padding: 12px 0; + border-bottom: 1px solid #ebebeb; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center + } -.swagger-ui .dialog-ux .modal-ux-header .close-modal { - padding: 0 10px; - border: none; - background: none; - -webkit-appearance: none; - -moz-appearance: none; - appearance: none -} + .swagger-ui .dialog-ux .modal-ux-header .close-modal { + padding: 0 10px; + border: none; + background: none; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none + } -.swagger-ui .dialog-ux .modal-ux-header h3 { - font-size: 20px; - font-weight: 600; - margin: 0; - padding: 0 20px; - -webkit-box-flex: 1; - -ms-flex: 1; - flex: 1; - font-family: Titillium Web, sans-serif; - color: #3b4151 -} + .swagger-ui .dialog-ux .modal-ux-header h3 { + font-size: 20px; + font-weight: 600; + margin: 0; + padding: 0 20px; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1; + font-family: Titillium Web, sans-serif; + color: #3b4151 + } .swagger-ui .model { font-size: 12px; @@ -1055,38 +1029,38 @@ transform-origin: 50% 50% } -.swagger-ui .model-toggle.collapsed { - -webkit-transform: rotate(0deg); - transform: rotate(0deg) -} + .swagger-ui .model-toggle.collapsed { + -webkit-transform: rotate(0deg); + transform: rotate(0deg) + } -.swagger-ui .model-toggle:after { - display: block; - width: 20px; - height: 20px; - content: ""; - background: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z'/%3E%3C/svg%3E") 50% no-repeat; - background-size: 100% -} + .swagger-ui .model-toggle:after { + display: block; + width: 20px; + height: 20px; + content: ""; + background: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z'/%3E%3C/svg%3E") 50% no-repeat; + background-size: 100% + } .swagger-ui .model-jump-to-path { position: relative; cursor: pointer } -.swagger-ui .model-jump-to-path .view-line-link { - position: absolute; - top: -.4em; - cursor: pointer -} + .swagger-ui .model-jump-to-path .view-line-link { + position: absolute; + top: -.4em; + cursor: pointer + } .swagger-ui .model-title { position: relative } -.swagger-ui .model-title:hover .model-hint { - visibility: visible -} + .swagger-ui .model-title:hover .model-hint { + visibility: visible + } .swagger-ui .model-hint { position: absolute; @@ -1105,87 +1079,87 @@ border-radius: 4px } -.swagger-ui section.models.is-open { - padding: 0 0 20px -} + .swagger-ui section.models.is-open { + padding: 0 0 20px + } -.swagger-ui section.models.is-open h4 { - margin: 0 0 5px; - border-bottom: 1px solid rgba(59, 65, 81, .3) -} + .swagger-ui section.models.is-open h4 { + margin: 0 0 5px; + border-bottom: 1px solid rgba(59, 65, 81, .3) + } -.swagger-ui section.models.is-open h4 svg { - -webkit-transform: rotate(90deg); - transform: rotate(90deg) -} + .swagger-ui section.models.is-open h4 svg { + -webkit-transform: rotate(90deg); + transform: rotate(90deg) + } -.swagger-ui section.models h4 { - font-size: 16px; - display: -webkit-box; - display: -ms-flexbox; - display: flex; - margin: 0; - padding: 10px 20px 10px 10px; - cursor: pointer; - -webkit-transition: all .2s; - transition: all .2s; - font-family: Titillium Web, sans-serif; - color: #777; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center -} + .swagger-ui section.models h4 { + font-size: 16px; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + margin: 0; + padding: 10px 20px 10px 10px; + cursor: pointer; + -webkit-transition: all .2s; + transition: all .2s; + font-family: Titillium Web, sans-serif; + color: #777; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center + } -.swagger-ui section.models h4 svg { - -webkit-transition: all .4s; - transition: all .4s -} + .swagger-ui section.models h4 svg { + -webkit-transition: all .4s; + transition: all .4s + } -.swagger-ui section.models h4 span { - -webkit-box-flex: 1; - -ms-flex: 1; - flex: 1 -} + .swagger-ui section.models h4 span { + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1 + } -.swagger-ui section.models h4:hover { - background: rgba(0, 0, 0, .02) -} + .swagger-ui section.models h4:hover { + background: rgba(0, 0, 0, .02) + } -.swagger-ui section.models h5 { - font-size: 16px; - margin: 0 0 10px; - font-family: Titillium Web, sans-serif; - color: #777 -} + .swagger-ui section.models h5 { + font-size: 16px; + margin: 0 0 10px; + font-family: Titillium Web, sans-serif; + color: #777 + } -.swagger-ui section.models .model-jump-to-path { - position: relative; - top: 5px -} + .swagger-ui section.models .model-jump-to-path { + position: relative; + top: 5px + } -.swagger-ui section.models .model-container { - margin: 0 20px 15px; - -webkit-transition: all .5s; - transition: all .5s; - border-radius: 4px; - background: rgba(0, 0, 0, .05) -} + .swagger-ui section.models .model-container { + margin: 0 20px 15px; + -webkit-transition: all .5s; + transition: all .5s; + border-radius: 4px; + background: rgba(0, 0, 0, .05) + } -.swagger-ui section.models .model-container:hover { - background: rgba(0, 0, 0, .07) -} + .swagger-ui section.models .model-container:hover { + background: rgba(0, 0, 0, .07) + } -.swagger-ui section.models .model-container:first-of-type { - margin: 20px -} + .swagger-ui section.models .model-container:first-of-type { + margin: 20px + } -.swagger-ui section.models .model-container:last-of-type { - margin: 0 20px -} + .swagger-ui section.models .model-container:last-of-type { + margin: 0 20px + } -.swagger-ui section.models .model-box { - background: none -} + .swagger-ui section.models .model-box { + background: none + } .swagger-ui .model-box { padding: 10px; @@ -1193,10 +1167,10 @@ background: rgba(0, 0, 0, .1) } -.swagger-ui .model-box .model-jump-to-path { - position: relative; - top: 4px -} + .swagger-ui .model-box .model-jump-to-path { + position: relative; + top: 4px + } .swagger-ui .model-title { font-size: 16px; @@ -1204,8 +1178,7 @@ color: #555 } -.swagger-ui span>span.model, -.swagger-ui span>span.model .brace-close { +.swagger-ui span > span.model, .swagger-ui span > span.model .brace-close { padding: 0 0 0 10px } @@ -1227,45 +1200,44 @@ border-collapse: collapse } -.swagger-ui table.model tbody tr td { - padding: 0; - vertical-align: top -} + .swagger-ui table.model tbody tr td { + padding: 0; + vertical-align: top + } -.swagger-ui table.model tbody tr td:first-of-type { - width: 100px; - padding: 0 -} + .swagger-ui table.model tbody tr td:first-of-type { + width: 100px; + padding: 0 + } -.swagger-ui table.headers td { - font-size: 12px; - font-weight: 300; - vertical-align: middle; - font-family: Source Code Pro, monospace; - font-weight: 600; - color: #3b4151 -} + .swagger-ui table.headers td { + font-size: 12px; + font-weight: 300; + vertical-align: middle; + font-family: Source Code Pro, monospace; + font-weight: 600; + color: #3b4151 + } -.swagger-ui table tbody tr td { - padding: 10px 0 0; - vertical-align: top -} + .swagger-ui table tbody tr td { + padding: 10px 0 0; + vertical-align: top + } -.swagger-ui table tbody tr td:first-of-type { - width: 20%; - padding: 10px 0 -} + .swagger-ui table tbody tr td:first-of-type { + width: 20%; + padding: 10px 0 + } -.swagger-ui table thead tr td, -.swagger-ui table thead tr th { - font-size: 12px; - font-weight: 700; - padding: 12px 0; - text-align: left; - border-bottom: 1px solid rgba(59, 65, 81, .2); - font-family: Open Sans, sans-serif; - color: #3b4151 -} + .swagger-ui table thead tr td, .swagger-ui table thead tr th { + font-size: 12px; + font-weight: 700; + padding: 12px 0; + text-align: left; + border-bottom: 1px solid rgba(59, 65, 81, .2); + font-family: Open Sans, sans-serif; + color: #3b4151 + } .swagger-ui .parameters-col_description p { font-size: 14px; @@ -1286,18 +1258,18 @@ color: #3b4151 } -.swagger-ui .parameter__name.required { - font-weight: 700 -} + .swagger-ui .parameter__name.required { + font-weight: 700 + } -.swagger-ui .parameter__name.required:after { - font-size: 10px; - position: relative; - top: -6px; - padding: 5px; - content: "required"; - color: rgba(255, 0, 0, .6) -} + .swagger-ui .parameter__name.required:after { + font-size: 10px; + position: relative; + top: -6px; + padding: 5px; + content: "required"; + color: rgba(255, 0, 0, .6) + } .swagger-ui .parameter__in { font-size: 12px; @@ -1316,141 +1288,140 @@ background-color: #89bf04 } -.swagger-ui .topbar .topbar-wrapper { - -ms-flex-align: center -} + .swagger-ui .topbar .topbar-wrapper { + -ms-flex-align: center + } -.swagger-ui .topbar .topbar-wrapper, -.swagger-ui .topbar a { - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-align: center; - align-items: center -} + .swagger-ui .topbar .topbar-wrapper, .swagger-ui .topbar a { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-align: center; + align-items: center + } -.swagger-ui .topbar a { - font-size: 1.5em; - font-weight: 700; - text-decoration: none; - -webkit-box-flex: 1; - -ms-flex: 1; - flex: 1; - -ms-flex-align: center; - font-family: Titillium Web, sans-serif; - color: #fff -} + .swagger-ui .topbar a { + font-size: 1.5em; + font-weight: 700; + text-decoration: none; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1; + -ms-flex-align: center; + font-family: Titillium Web, sans-serif; + color: #fff + } -.swagger-ui .topbar a span { - margin: 0; - padding: 0 10px -} + .swagger-ui .topbar a span { + margin: 0; + padding: 0 10px + } -.swagger-ui .topbar .download-url-wrapper { - display: -webkit-box; - display: -ms-flexbox; - display: flex -} + .swagger-ui .topbar .download-url-wrapper { + display: -webkit-box; + display: -ms-flexbox; + display: flex + } -.swagger-ui .topbar .download-url-wrapper label.select-label span { - color: white; -} + .swagger-ui .topbar .download-url-wrapper label.select-label span { + color: white; + } -.swagger-ui .topbar .download-url-wrapper input[type=text] { - min-width: 350px; - margin: 0; - border: 2px solid #547f00; - border-radius: 4px 0 0 4px; - outline: none -} + .swagger-ui .topbar .download-url-wrapper input[type=text] { + min-width: 350px; + margin: 0; + border: 2px solid #547f00; + border-radius: 4px 0 0 4px; + outline: none + } -.swagger-ui .topbar .download-url-wrapper .download-url-button { - font-size: 16px; - font-weight: 700; - padding: 4px 40px; - border: none; - border-radius: 0 4px 4px 0; - background: #547f00; - font-family: Titillium Web, sans-serif; - color: #fff -} + .swagger-ui .topbar .download-url-wrapper .download-url-button { + font-size: 16px; + font-weight: 700; + padding: 4px 40px; + border: none; + border-radius: 0 4px 4px 0; + background: #547f00; + font-family: Titillium Web, sans-serif; + color: #fff + } .swagger-ui .info { margin: 50px 0 } -.swagger-ui .info hgroup.main { - margin: 0 0 20px -} + .swagger-ui .info hgroup.main { + margin: 0 0 20px + } -.swagger-ui .info hgroup.main a { - font-size: 12px -} + .swagger-ui .info hgroup.main a { + font-size: 12px + } -.swagger-ui .info p { - font-size: 14px; - font-family: Open Sans, sans-serif; - color: #3b4151 -} + .swagger-ui .info p { + font-size: 14px; + font-family: Open Sans, sans-serif; + color: #3b4151 + } -.swagger-ui .info code { - padding: 3px 5px; - border-radius: 4px; - background: rgba(0, 0, 0, .05); - font-family: Source Code Pro, monospace; - font-weight: 600; - color: #9012fe -} + .swagger-ui .info code { + padding: 3px 5px; + border-radius: 4px; + background: rgba(0, 0, 0, .05); + font-family: Source Code Pro, monospace; + font-weight: 600; + color: #9012fe + } -.swagger-ui .info a { - font-size: 14px; - -webkit-transition: all .4s; - transition: all .4s; - font-family: Open Sans, sans-serif; - color: #4990e2 -} + .swagger-ui .info a { + font-size: 14px; + -webkit-transition: all .4s; + transition: all .4s; + font-family: Open Sans, sans-serif; + color: #4990e2 + } -.swagger-ui .info a:hover { - color: #1f69c0 -} + .swagger-ui .info a:hover { + color: #1f69c0 + } -.swagger-ui .info>div { - margin: 0 0 5px -} + .swagger-ui .info > div { + margin: 0 0 5px + } -.swagger-ui .info .base-url { - font-size: 12px; - font-weight: 300 !important; - margin: 0; - font-family: Source Code Pro, monospace; - font-weight: 600; - color: #3b4151 -} + .swagger-ui .info .base-url { + font-size: 12px; + font-weight: 300 !important; + margin: 0; + font-family: Source Code Pro, monospace; + font-weight: 600; + color: #3b4151 + } -.swagger-ui .info .title { - font-size: 36px; - margin: 0; - font-family: Open Sans, sans-serif; - color: #3b4151 -} + .swagger-ui .info .title { + font-size: 36px; + margin: 0; + font-family: Open Sans, sans-serif; + color: #3b4151 + } -.swagger-ui .info .title small { - font-size: 10px; - position: relative; - top: -5px; - display: inline-block; - margin: 0 0 0 5px; - padding: 2px 4px; - vertical-align: super; - border-radius: 57px; - background: #7d8492 -} + .swagger-ui .info .title small { + font-size: 10px; + position: relative; + top: -5px; + display: inline-block; + margin: 0 0 0 5px; + padding: 2px 4px; + vertical-align: super; + border-radius: 57px; + background: #7d8492 + } -.swagger-ui .info .title small pre { - margin: 0; - font-family: Titillium Web, sans-serif; - color: #fff -} + .swagger-ui .info .title small pre { + margin: 0; + font-family: Titillium Web, sans-serif; + color: #fff + } .swagger-ui .auth-btn-wrapper { display: -webkit-box; @@ -1474,9 +1445,9 @@ justify-content: flex-end } -.swagger-ui .auth-wrapper .authorize { - padding-right: 20px -} + .swagger-ui .auth-wrapper .authorize { + padding-right: 20px + } .swagger-ui .auth-container { margin: 0 0 10px; @@ -1484,34 +1455,33 @@ border-bottom: 1px solid #ebebeb } -.swagger-ui .auth-container:last-of-type { - margin: 0; - padding: 10px 20px; - border: 0 -} + .swagger-ui .auth-container:last-of-type { + margin: 0; + padding: 10px 20px; + border: 0 + } -.swagger-ui .auth-container h4 { - margin: 5px 0 15px !important -} + .swagger-ui .auth-container h4 { + margin: 5px 0 15px !important + } -.swagger-ui .auth-container .wrapper { - margin: 0; - padding: 0 -} + .swagger-ui .auth-container .wrapper { + margin: 0; + padding: 0 + } -.swagger-ui .auth-container input[type=password], -.swagger-ui .auth-container input[type=text] { - min-width: 230px -} + .swagger-ui .auth-container input[type=password], .swagger-ui .auth-container input[type=text] { + min-width: 230px + } -.swagger-ui .auth-container .errors { - font-size: 12px; - padding: 10px; - border-radius: 4px; - font-family: Source Code Pro, monospace; - font-weight: 600; - color: #3b4151 -} + .swagger-ui .auth-container .errors { + font-size: 12px; + padding: 10px; + border-radius: 4px; + font-family: Source Code Pro, monospace; + font-weight: 600; + color: #3b4151 + } .swagger-ui .scopes h2 { font-size: 14px; @@ -1533,36 +1503,36 @@ background: rgba(249, 62, 62, .1) } -.swagger-ui .errors-wrapper .error-wrapper { - margin: 0 0 10px -} + .swagger-ui .errors-wrapper .error-wrapper { + margin: 0 0 10px + } -.swagger-ui .errors-wrapper .errors h4 { - font-size: 14px; - margin: 0; - font-family: Source Code Pro, monospace; - font-weight: 600; - color: #3b4151 -} + .swagger-ui .errors-wrapper .errors h4 { + font-size: 14px; + margin: 0; + font-family: Source Code Pro, monospace; + font-weight: 600; + color: #3b4151 + } -.swagger-ui .errors-wrapper hgroup { - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center -} + .swagger-ui .errors-wrapper hgroup { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center + } -.swagger-ui .errors-wrapper hgroup h4 { - font-size: 20px; - margin: 0; - -webkit-box-flex: 1; - -ms-flex: 1; - flex: 1; - font-family: Titillium Web, sans-serif; - color: #3b4151 -} + .swagger-ui .errors-wrapper hgroup h4 { + font-size: 20px; + margin: 0; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1; + font-family: Titillium Web, sans-serif; + color: #3b4151 + } @-webkit-keyframes scaleUp { 0% { @@ -1611,144 +1581,144 @@ background: #ffffff; } -.swagger-ui .opblock.opblock-post .opblock-summary-method { - background: #009688; -} + .swagger-ui .opblock.opblock-post .opblock-summary-method { + background: #009688; + } -.swagger-ui .opblock.opblock-post .opblock-summary { - border-color: #ffffff; -} + .swagger-ui .opblock.opblock-post .opblock-summary { + border-color: #ffffff; + } -.swagger-ui .opblock.opblock-post .tab-header .tab-item.active h4 span:after { - background: #009688; -} + .swagger-ui .opblock.opblock-post .tab-header .tab-item.active h4 span:after { + background: #009688; + } .swagger-ui .opblock.opblock-put { border-color: #ffffff; background: #ffffff; } -.swagger-ui .opblock.opblock-put .opblock-summary-method { - background: #ff9800; -} + .swagger-ui .opblock.opblock-put .opblock-summary-method { + background: #ff9800; + } -.swagger-ui .opblock.opblock-put .opblock-summary { - border-color: #ffffff; -} + .swagger-ui .opblock.opblock-put .opblock-summary { + border-color: #ffffff; + } -.swagger-ui .opblock.opblock-put .tab-header .tab-item.active h4 span:after { - background: #ff9800; -} + .swagger-ui .opblock.opblock-put .tab-header .tab-item.active h4 span:after { + background: #ff9800; + } .swagger-ui .opblock.opblock-delete { border-color: #ffffff; background: #ffffff; } -.swagger-ui .opblock.opblock-delete .opblock-summary-method { - background: #f44336; -} + .swagger-ui .opblock.opblock-delete .opblock-summary-method { + background: #f44336; + } -.swagger-ui .opblock.opblock-delete .opblock-summary { - border-color: #ffffff; -} + .swagger-ui .opblock.opblock-delete .opblock-summary { + border-color: #ffffff; + } -.swagger-ui .opblock.opblock-delete .tab-header .tab-item.active h4 span:after { - background: #f44336; -} + .swagger-ui .opblock.opblock-delete .tab-header .tab-item.active h4 span:after { + background: #f44336; + } .swagger-ui .opblock.opblock-get { border-color: #ffffff; background: #ffffff; } -.swagger-ui .opblock.opblock-get .opblock-summary-method { - background: #3f51b5; -} + .swagger-ui .opblock.opblock-get .opblock-summary-method { + background: #3f51b5; + } -.swagger-ui .opblock.opblock-get .opblock-summary { - border-color: #ffffff; -} + .swagger-ui .opblock.opblock-get .opblock-summary { + border-color: #ffffff; + } -.swagger-ui .opblock.opblock-get .tab-header .tab-item.active h4 span:after { - background: #3f51b5; -} + .swagger-ui .opblock.opblock-get .tab-header .tab-item.active h4 span:after { + background: #3f51b5; + } .swagger-ui .opblock.opblock-patch { border-color: #ffffff; background: #ffffff; } -.swagger-ui .opblock.opblock-patch .opblock-summary-method { - background: #f57c00; -} + .swagger-ui .opblock.opblock-patch .opblock-summary-method { + background: #f57c00; + } -.swagger-ui .opblock.opblock-patch .opblock-summary { - border-color: #ffffff; -} + .swagger-ui .opblock.opblock-patch .opblock-summary { + border-color: #ffffff; + } -.swagger-ui .opblock.opblock-patch .tab-header .tab-item.active h4 span:after { - background: #f57c00; -} + .swagger-ui .opblock.opblock-patch .tab-header .tab-item.active h4 span:after { + background: #f57c00; + } .swagger-ui .opblock.opblock-head { border-color: #ffffff; background: #ffffff; } -.swagger-ui .opblock.opblock-head .opblock-summary-method { - background: #3f51b5; -} + .swagger-ui .opblock.opblock-head .opblock-summary-method { + background: #3f51b5; + } -.swagger-ui .opblock.opblock-head .opblock-summary { - border-color: #ffffff; -} + .swagger-ui .opblock.opblock-head .opblock-summary { + border-color: #ffffff; + } -.swagger-ui .opblock.opblock-head .tab-header .tab-item.active h4 span:after { - background: #3f51b5; -} + .swagger-ui .opblock.opblock-head .tab-header .tab-item.active h4 span:after { + background: #3f51b5; + } .swagger-ui .opblock.opblock-options { border-color: #ffffff; background: #ffffff; } -.swagger-ui .opblock.opblock-options .opblock-summary-method { - background: #3f51b5; -} + .swagger-ui .opblock.opblock-options .opblock-summary-method { + background: #3f51b5; + } -.swagger-ui .opblock.opblock-options .opblock-summary { - border-color: #ffffff; -} + .swagger-ui .opblock.opblock-options .opblock-summary { + border-color: #ffffff; + } -.swagger-ui .opblock.opblock-options .tab-header .tab-item.active h4 span:after { - background: #3f51b5; -} + .swagger-ui .opblock.opblock-options .tab-header .tab-item.active h4 span:after { + background: #3f51b5; + } .swagger-ui .topbar { padding: 8px 30px; background-color: #3f51b5; - box-shadow: 0 5px 5px 0 rgba(0, 0, 0, .4), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12); + box-shadow: 0 5px 5px 0 rgba(0,0,0,.4), 0 3px 1px -2px rgba(0,0,0,.2), 0 1px 5px 0 rgba(0,0,0,.12); } -.swagger-ui .topbar .download-url-wrapper input[type=text] { - min-width: 350px; - margin: 0; - border: 2px solid #DADFE1; - border-radius: 4px 0 0 4px; - outline: none; -} + .swagger-ui .topbar .download-url-wrapper input[type=text] { + min-width: 350px; + margin: 0; + border: 2px solid #DADFE1; + border-radius: 4px 0 0 4px; + outline: none; + } -.swagger-ui .topbar .download-url-wrapper .download-url-button { - font-size: 16px; - font-weight: 700; - padding: 4px 40px; - border: none; - border-radius: 0 4px 4px 0; - background: #ffffff; - font-family: Titillium Web, sans-serif; - color: #222222; -} + .swagger-ui .topbar .download-url-wrapper .download-url-button { + font-size: 16px; + font-weight: 700; + padding: 4px 40px; + border: none; + border-radius: 0 4px 4px 0; + background: #ffffff; + font-family: Titillium Web, sans-serif; + color: #222222; + } .swagger-ui .info a { font-size: 14px; @@ -1758,9 +1728,9 @@ color: #3f51b5; } -.swagger-ui .info a:hover { - color: #3f51b5; -} + .swagger-ui .info a:hover { + color: #3f51b5; + } .swagger-ui .btn.authorize { line-height: 1; @@ -1769,19 +1739,19 @@ border-color: #3f51b5; } -.swagger-ui .btn.authorize svg { - fill: #3f51b5; -} + .swagger-ui .btn.authorize svg { + fill: #3f51b5; + } body { margin: 0; background: #ffffff; - font-family: "Roboto", "Helvetica", "Arial", sans-serif; + font-family: "Roboto","Helvetica","Arial",sans-serif; } .swagger-ui .opblock { margin: 0 0 15px; border: none; border-radius: 2px; - box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12); -} \ No newline at end of file + box-shadow: 0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.2),0 1px 5px 0 rgba(0,0,0,.12); +} diff --git a/src/HelloShop.WebApp/HelloShop.WebApp.csproj b/src/HelloShop.WebApp/HelloShop.WebApp.csproj index ec25ce8..73123f7 100644 --- a/src/HelloShop.WebApp/HelloShop.WebApp.csproj +++ b/src/HelloShop.WebApp/HelloShop.WebApp.csproj @@ -1,7 +1,7 @@ Exe - net9.0 + net8.0 enable enable diff --git a/src/HelloShop.WebApp/Program.cs b/src/HelloShop.WebApp/Program.cs index 14284a8..86cdae3 100644 --- a/src/HelloShop.WebApp/Program.cs +++ b/src/HelloShop.WebApp/Program.cs @@ -1,3 +1,6 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + using HelloShop.WebApp; using HelloShop.WebApp.Components; @@ -12,7 +15,7 @@ builder.Services.AddRazorComponents() builder.Services.AddOutputCache(); -builder.Services.AddHttpClient(client=> client.BaseAddress = new("http://apiservice")); +builder.Services.AddHttpClient(client => client.BaseAddress = new("http://apiservice")); var app = builder.Build(); @@ -29,7 +32,7 @@ app.UseOutputCache(); app.MapRazorComponents() .AddInteractiveServerRenderMode(); - + app.MapDefaultEndpoints(); app.Run(); diff --git a/src/HelloShop.WebApp/Properties/launchSettings.json b/src/HelloShop.WebApp/Properties/launchSettings.json index 964adaf..888745b 100644 --- a/src/HelloShop.WebApp/Properties/launchSettings.json +++ b/src/HelloShop.WebApp/Properties/launchSettings.json @@ -1,14 +1,23 @@ { - "$schema": "http://json.schemastore.org/launchsettings.json", + "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { "http": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "http://localhost:5058", + "applicationUrl": "http://localhost:8000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:8181;http://localhost:8080", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } -} +} \ No newline at end of file diff --git a/src/HelloShop.WebApp/WeatherApiClient.cs b/src/HelloShop.WebApp/WeatherApiClient.cs index c8e90a5..493fc94 100644 --- a/src/HelloShop.WebApp/WeatherApiClient.cs +++ b/src/HelloShop.WebApp/WeatherApiClient.cs @@ -1,3 +1,6 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + namespace HelloShop.WebApp; public class WeatherApiClient(HttpClient httpClient) diff --git a/tests/HelloShop.FunctionalTests/FirstWebApiIntegrationTest.cs b/tests/HelloShop.FunctionalTests/FirstWebApiIntegrationTest.cs new file mode 100644 index 0000000..3f9de8b --- /dev/null +++ b/tests/HelloShop.FunctionalTests/FirstWebApiIntegrationTest.cs @@ -0,0 +1,128 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.AspNetCore.Authentication.BearerToken; +using System.Dynamic; +using System.Net; +using System.Net.Http.Headers; +using System.Net.Http.Json; +using System.Text.Json.Nodes; + +namespace HelloShop.FunctionalTests +{ + public class FirstWebApiIntegrationTest + { + [Fact] + public async Task WebAppRootReturnsOkStatusCode() + { + // Arrange + IDistributedApplicationTestingBuilder appHost = await DistributedApplicationTestingBuilder.CreateAsync(); + await using DistributedApplication app = await appHost.BuildAsync(); + await app.StartAsync(); + + // Act + HttpClient httpClient = app.CreateHttpClient("webapp"); + HttpResponseMessage response = await httpClient.GetAsync("/"); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + } + + [Fact] + public async Task IdetityServiceAccountLoginReturnsSuccessStatusCode() + { + // Arrange + IDistributedApplicationTestingBuilder appHost = await DistributedApplicationTestingBuilder.CreateAsync(); + await using DistributedApplication app = await appHost.BuildAsync(); + await app.StartAsync(); + + // Act + HttpClient httpClient = app.CreateHttpClient("identityservice"); + HttpResponseMessage response = await httpClient.PostAsJsonAsync("api/Account/Login", new + { + UserName = "guest", + Password = "guest" + }); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + } + + [Fact] + public async Task IdetityServiceAccountLoginReturnsAccessToken() + { + // Arrange + IDistributedApplicationTestingBuilder appHost = await DistributedApplicationTestingBuilder.CreateAsync(); + await using DistributedApplication app = await appHost.BuildAsync(); + await app.StartAsync(); + + // Act + HttpClient httpClient = app.CreateHttpClient("identityservice"); + HttpResponseMessage response = await httpClient.PostAsJsonAsync("api/Account/Login", new + { + UserName = "guest", + Password = "guest" + }); + dynamic? result = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.NotNull(result?.accessToken); + } + + [Fact] + public async Task IdetityServiceAccountLoginReturnsTokenExpiresInSeconds() + { + // Arrange + IDistributedApplicationTestingBuilder appHost = await DistributedApplicationTestingBuilder.CreateAsync(); + await using DistributedApplication app = await appHost.BuildAsync(); + + await app.StartAsync(); + + // Act + HttpClient httpClient = app.CreateHttpClient("identityservice"); + HttpResponseMessage response = await httpClient.PostAsJsonAsync("api/Account/Login", new + { + UserName = "guest", + Password = "guest" + }); + JsonNode? result = await response.Content.ReadFromJsonAsync(); + int expiresInSeconds = result?["expiresIn"]?.GetValue() ?? default; + + // Assert + Assert.Equal(3600, expiresInSeconds); + } + + [Fact] + public async Task ProductServiceGetProductReturnsProductDetails() + { + // Arrange + IDistributedApplicationTestingBuilder appHost = await DistributedApplicationTestingBuilder.CreateAsync(); + + await using DistributedApplication app = await appHost.BuildAsync(); + await app.StartAsync(); + + // Act + HttpClient identityServiceHttpClient = app.CreateHttpClient("identityservice"); + HttpResponseMessage loginResponse = await identityServiceHttpClient.PostAsJsonAsync("api/Account/Login", new + { + UserName = "admin", + Password = "admin" + }); + + AccessTokenResponse? accessTokenResponse = await loginResponse.Content.ReadFromJsonAsync(); + + HttpClient productServiceHttpClient = app.CreateHttpClient("productservice"); + productServiceHttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessTokenResponse?.AccessToken); + + HttpResponseMessage productDetailsResponse = await productServiceHttpClient.GetAsync("api/Products/1"); + + JsonNode? result = await productDetailsResponse.Content.ReadFromJsonAsync(); + + string? productName = result?["Name"]?.GetValue(); + + // Assert + Assert.NotNull(productName); + Assert.Equal("Product 1", productName); + } + } +} \ No newline at end of file diff --git a/tests/HelloShop.FunctionalTests/HelloShop.FunctionalTests.csproj b/tests/HelloShop.FunctionalTests/HelloShop.FunctionalTests.csproj new file mode 100644 index 0000000..1457a01 --- /dev/null +++ b/tests/HelloShop.FunctionalTests/HelloShop.FunctionalTests.csproj @@ -0,0 +1,28 @@ + + + + net8.0 + enable + enable + false + true + + + + + + + + + + + + + + + + + + + + diff --git a/tests/HelloShop.ProductService.FunctionalTests/BrandApiIntegrationTest.cs b/tests/HelloShop.ProductService.FunctionalTests/BrandApiIntegrationTest.cs new file mode 100644 index 0000000..5e53675 --- /dev/null +++ b/tests/HelloShop.ProductService.FunctionalTests/BrandApiIntegrationTest.cs @@ -0,0 +1,42 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ProductService.FunctionalTests.Utilities; +using HelloShop.ProductService.Models.Products; +using System.Net; +using System.Net.Http.Json; + +namespace HelloShop.ProductService.FunctionalTests +{ + public class BrandApiIntegrationTest(CustomWebApplicationFactory factory) : IClassFixture> + { + [Fact] + public async Task GetBrandByIdReturnsUnauthorizedStatusCode() + { + // Arrange + HttpClient client = factory.CreateClient(); + + // Act + HttpResponseMessage response = await client.GetAsync("api/Brands/1"); + + // Assert + Assert.Equal(HttpStatusCode.OK, response.StatusCode); + + } + + [Fact] + public async Task GetBrandByIdReturnsBrandDetailsResponse() + { + // Arrange + HttpClient client = factory.CreateClient(); + + // Act + HttpResponseMessage response = await client.GetAsync("api/Brands/1"); + BrandDetailsResponse? brandDetails = await response.Content.ReadFromJsonAsync(); + + // Assert + Assert.NotNull(brandDetails); + Assert.Equal(1, brandDetails.Id); + } + } +} \ No newline at end of file diff --git a/tests/HelloShop.ProductService.FunctionalTests/GlobalUsings.cs b/tests/HelloShop.ProductService.FunctionalTests/GlobalUsings.cs deleted file mode 100644 index 8c927eb..0000000 --- a/tests/HelloShop.ProductService.FunctionalTests/GlobalUsings.cs +++ /dev/null @@ -1 +0,0 @@ -global using Xunit; \ No newline at end of file diff --git a/tests/HelloShop.ProductService.FunctionalTests/HelloShop.ProductService.FunctionalTests.csproj b/tests/HelloShop.ProductService.FunctionalTests/HelloShop.ProductService.FunctionalTests.csproj index 430f7ed..6489c44 100644 --- a/tests/HelloShop.ProductService.FunctionalTests/HelloShop.ProductService.FunctionalTests.csproj +++ b/tests/HelloShop.ProductService.FunctionalTests/HelloShop.ProductService.FunctionalTests.csproj @@ -1,21 +1,35 @@ - - net9.0 - enable - enable - false - true - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - \ No newline at end of file + + + net8.0 + enable + enable + + false + true + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + diff --git a/tests/HelloShop.ProductService.FunctionalTests/UnitTest1.cs b/tests/HelloShop.ProductService.FunctionalTests/UnitTest1.cs deleted file mode 100644 index 867481c..0000000 --- a/tests/HelloShop.ProductService.FunctionalTests/UnitTest1.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace HelloShop.ProductService.FunctionalTests -{ - public class UnitTest1 - { - [Fact] - public void Test1() - { - - } - } -} \ No newline at end of file diff --git a/tests/HelloShop.ProductService.FunctionalTests/Utilities/CustomWebApplicationFactory.cs b/tests/HelloShop.ProductService.FunctionalTests/Utilities/CustomWebApplicationFactory.cs new file mode 100644 index 0000000..4dbf993 --- /dev/null +++ b/tests/HelloShop.ProductService.FunctionalTests/Utilities/CustomWebApplicationFactory.cs @@ -0,0 +1,59 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ProductService.EntityFrameworks; +using HelloShop.ServiceDefaults.Authorization; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.Data.Sqlite; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Hosting; +using System.Data.Common; +using System.Net.Http.Headers; + +namespace HelloShop.ProductService.FunctionalTests.Utilities +{ + public class CustomWebApplicationFactory : WebApplicationFactory where TProgram : class + { + protected override void ConfigureWebHost(IWebHostBuilder builder) + { + builder.ConfigureServices(services => + { + ServiceDescriptor? dbContextDescriptor = services.SingleOrDefault(d => d.ServiceType == typeof(DbContextOptions)); + + if (dbContextDescriptor != null) + { + services.Remove(dbContextDescriptor); + } + + // Create open SqliteConnection so EF won't automatically close it. + services.AddSingleton(container => + { + DbConnection connection = new SqliteConnection("DataSource=:memory:"); + connection.Open(); + + return connection; + }); + + services.AddDbContext((container, options) => + { + var connection = container.GetRequiredService(); + options.UseSqlite(connection); + }); + + services.Replace(ServiceDescriptor.Transient()); + }); + + builder.UseEnvironment(Environments.Development); + } + + protected override void ConfigureClient(HttpClient client) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", FakeAccessTokenCreator.Create()); + + base.ConfigureClient(client); + } + } +} diff --git a/tests/HelloShop.ProductService.FunctionalTests/Utilities/FakeAccessTokenCreator.cs b/tests/HelloShop.ProductService.FunctionalTests/Utilities/FakeAccessTokenCreator.cs new file mode 100644 index 0000000..ccb5c97 --- /dev/null +++ b/tests/HelloShop.ProductService.FunctionalTests/Utilities/FakeAccessTokenCreator.cs @@ -0,0 +1,36 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ServiceDefaults.Constants; +using Microsoft.IdentityModel.Tokens; +using System.IdentityModel.Tokens.Jwt; +using System.Security.Claims; +using System.Text; + +namespace HelloShop.ProductService.FunctionalTests.Utilities +{ + public class FakeAccessTokenCreator + { + public static string Create() + { + DateTimeOffset utcNow = TimeProvider.System.GetUtcNow(); + + SymmetricSecurityKey signingKey = new(Encoding.Default.GetBytes(IdentityConstants.IssuerSigningKey)); + + var claimsIdentity = new ClaimsIdentity([new Claim(ClaimTypes.NameIdentifier, "1"), new Claim(ClaimTypes.Name, "admin"), new Claim(CustomClaimTypes.RoleIdentifier, "1")]); + + SecurityTokenDescriptor accessTokenDescriptor = new() + { + Subject = claimsIdentity, + SigningCredentials = new(signingKey, SecurityAlgorithms.HmacSha256), + Expires = utcNow.Add(TimeSpan.FromDays(byte.MaxValue)).LocalDateTime, + }; + + JwtSecurityTokenHandler tokenHandler = new(); + + JwtSecurityToken jwtSecurityToken = tokenHandler.CreateJwtSecurityToken(accessTokenDescriptor); + + return tokenHandler.WriteToken(jwtSecurityToken); + } + } +} \ No newline at end of file diff --git a/tests/HelloShop.ProductService.UnitTests/GlobalUsings.cs b/tests/HelloShop.ProductService.UnitTests/GlobalUsings.cs deleted file mode 100644 index 8c927eb..0000000 --- a/tests/HelloShop.ProductService.UnitTests/GlobalUsings.cs +++ /dev/null @@ -1 +0,0 @@ -global using Xunit; \ No newline at end of file diff --git a/tests/HelloShop.ProductService.UnitTests/HelloShop.ProductService.UnitTests.csproj b/tests/HelloShop.ProductService.UnitTests/HelloShop.ProductService.UnitTests.csproj index 430f7ed..d3cf251 100644 --- a/tests/HelloShop.ProductService.UnitTests/HelloShop.ProductService.UnitTests.csproj +++ b/tests/HelloShop.ProductService.UnitTests/HelloShop.ProductService.UnitTests.csproj @@ -1,21 +1,35 @@ - - net9.0 - enable - enable - false - true - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - + + + net8.0 + enable + enable + + false + true + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + \ No newline at end of file diff --git a/tests/HelloShop.ProductService.UnitTests/MockProductsControllerTest.cs b/tests/HelloShop.ProductService.UnitTests/MockProductsControllerTest.cs new file mode 100644 index 0000000..2fd3b83 --- /dev/null +++ b/tests/HelloShop.ProductService.UnitTests/MockProductsControllerTest.cs @@ -0,0 +1,62 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using AutoMapper; +using HelloShop.ProductService.Controllers; +using HelloShop.ProductService.Entities.Products; +using HelloShop.ProductService.Models.Products; +using HelloShop.ProductService.Services; +using Microsoft.AspNetCore.Mvc; +using Moq; + +namespace HelloShop.ProductService.UnitTests +{ + public class MockProductsControllerTest + { + [Fact] + public async Task GetProductReturnsNotFoundIfNotExists() + { + // Arrange + Mock mock = new(); + + mock.Setup(m => m.FindAsync(It.Is(id => id == 1), It.IsAny())).ReturnsAsync((Product?)null); + + // Act + IMapper mapper = new Mapper(new MapperConfiguration(cfg => cfg.CreateMap())); + MockProductsController mockProductsController = new(mock.Object, mapper); + ActionResult result = await mockProductsController.GetProduct(1); + + //Assert + Assert.IsType(result.Result); + } + + [Fact] + public async Task GetAllReturnsPorductListItems() + { + // Arrange + Mock mock = new(); + + mock.Setup(m => m.GetAllAsync(It.IsAny())).ReturnsAsync([new Product { Id = 1, Name = "Product 1", Price = 10 }, new Product { Id = 2, Name = "Product 2", Price = 20 }]); + + // Act + IMapper mapper = new Mapper(new MapperConfiguration(cfg => cfg.CreateMap())); + MockProductsController mockProductsController = new(mock.Object, mapper); + ActionResult> result = await mockProductsController.GetProducts(); + + //Assert + Assert.NotNull(result.Value); + + Assert.Collection(result.Value, productListItem1 => + { + Assert.Equal(1, productListItem1.Id); + Assert.Equal("Product 1", productListItem1.Name); + Assert.Equal(10, productListItem1.Price); + }, productListItem2 => + { + Assert.Equal(2, productListItem2.Id); + Assert.Equal("Product 2", productListItem2.Name); + Assert.Equal(20, productListItem2.Price); + }); + } + } +} \ No newline at end of file diff --git a/tests/HelloShop.ProductService.UnitTests/ProductsControllerTest.cs b/tests/HelloShop.ProductService.UnitTests/ProductsControllerTest.cs new file mode 100644 index 0000000..10db17e --- /dev/null +++ b/tests/HelloShop.ProductService.UnitTests/ProductsControllerTest.cs @@ -0,0 +1,61 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using AutoMapper; +using HelloShop.ProductService.AutoMapper; +using HelloShop.ProductService.Entities.Products; +using HelloShop.ProductService.Models.Products; +using HelloShop.ProductService.UnitTests.Utilities; +using Microsoft.AspNetCore.Mvc; + +namespace HelloShop.ProductService.UnitTests +{ + public class ProductsControllerTest + { + [Fact] + public async Task GetProductByIdReturnsProductDetailsResponse() + { + // Arrange + await using EntityFrameworks.ProductServiceDbContext dbContext = new FakeDbContextFactory().CreateDbContext(); + + await dbContext.AddAsync(new Product { Id = 1, Name = "Product 1", Price = 10 }); + + await dbContext.SaveChangesAsync(); + + IMapper mapper = new MapperConfiguration(configure => configure.CreateMap()).CreateMapper(); + + ProductsController productsController = new(dbContext, mapper); + + // Act + ActionResult result = await productsController.GetProduct(1); + + //Assert + Assert.Equal(10, result.Value?.Price); + } + + [Theory] + [InlineData("Product 1", 10)] + [InlineData("Product 2", 20)] + [InlineData("Product 3", 30)] + public async Task PostProductReturnsProductDetailsResponse(string productName, decimal price) + { + // Arrange + await using EntityFrameworks.ProductServiceDbContext dbContext = new FakeDbContextFactory().CreateDbContext(); + + IMapper mapper = new MapperConfiguration(configure => configure.AddProfile()).CreateMapper(); + + ProductsController productsController = new(dbContext, mapper); + + // Act + ActionResult createdAtActionResult = await productsController.PostProduct(new ProductCreateRequest { Name = productName, Price = price }); + ProductDetailsResponse? result = (createdAtActionResult?.Result as CreatedAtActionResult)?.Value as ProductDetailsResponse; + + //Assert + Assert.Multiple(() => + { + Assert.Equal(price, result?.Price); + Assert.Equal(productName, result?.Name); + }); + } + } +} \ No newline at end of file diff --git a/tests/HelloShop.ProductService.UnitTests/README.md b/tests/HelloShop.ProductService.UnitTests/README.md new file mode 100644 index 0000000..2b49724 --- /dev/null +++ b/tests/HelloShop.ProductService.UnitTests/README.md @@ -0,0 +1,29 @@ +# Unit test bast practices + +## Unit testing best practices with .NET Core and .NET Standard + +https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-best-practices + +## Testing without your production database system + +https://learn.microsoft.com/en-us/ef/core/testing/testing-without-the-database + +## Unit test controller logic in ASP.NET Core + +https://learn.microsoft.com/en-us/ef/core/testing/testing-without-the-database + +## Unit and integration tests in Minimal API apps + +https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis/test-min-api + +## Integration tests in ASP.NET Core + +https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests + +## Use Moq with xUnit in .NET Core unit tests + +https://github.com/devlooped/moq + +## Test gRPC services in ASP.NET Core + +https://learn.microsoft.com/en-us/aspnet/core/grpc/test-services diff --git a/tests/HelloShop.ProductService.UnitTests/UnitTest1.cs b/tests/HelloShop.ProductService.UnitTests/UnitTest1.cs deleted file mode 100644 index 24e2cf2..0000000 --- a/tests/HelloShop.ProductService.UnitTests/UnitTest1.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace HelloShop.ProductService.UnitTests -{ - public class UnitTest1 - { - [Fact] - public void Test1() - { - - } - } -} \ No newline at end of file diff --git a/tests/HelloShop.ProductService.UnitTests/Utilities/FakeDbContextFactory.cs b/tests/HelloShop.ProductService.UnitTests/Utilities/FakeDbContextFactory.cs new file mode 100644 index 0000000..1f72208 --- /dev/null +++ b/tests/HelloShop.ProductService.UnitTests/Utilities/FakeDbContextFactory.cs @@ -0,0 +1,18 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using HelloShop.ProductService.EntityFrameworks; +using Microsoft.EntityFrameworkCore; + +namespace HelloShop.ProductService.UnitTests.Utilities +{ + public class FakeDbContextFactory : IDbContextFactory + { + public ProductServiceDbContext CreateDbContext() + { + var options = new DbContextOptionsBuilder().UseInMemoryDatabase($"InMemoryTestDb-{DateTimeOffset.UtcNow.ToFileTime()}").Options; + + return new ProductServiceDbContext(options); + } + } +} \ No newline at end of file