diff --git a/deploy/az/servicebus/readme.md b/deploy/az/servicebus/readme.md index 3ed8e8a0e..16da4c7b2 100644 --- a/deploy/az/servicebus/readme.md +++ b/deploy/az/servicebus/readme.md @@ -3,7 +3,7 @@ The ARM template `sbusdeploy.json` and its parameter file (`sbusdeploy.parameters.json`) are used to deploy following resources: 1. One Service Bus namespace -2. One Service Bus +2. One Service Bus topic 3. Subscriptions used by application ## Editing sbusdeploy.parameters.json file @@ -17,17 +17,8 @@ be set is: Once parameter file is edited you can deploy it using [create-resources script](../readme.md). -i. e. if you are in windows, to deploy sql databases in a new resourcegroup located in westus, go to `deploy\az` folder and type: +i. e. if you are in windows, to deploy servicebus in a new resourcegroup located in westus, go to `deploy\az` folder and type: ``` create-resources.cmd servicebus\sbusdeploy newResourceGroup -c westus -``` - - - - - - - - - +``` \ No newline at end of file diff --git a/deploy/az/storage/marketing/readme.md b/deploy/az/storage/marketing/readme.md index 2b457b608..c0ec2be7a 100644 --- a/deploy/az/storage/marketing/readme.md +++ b/deploy/az/storage/marketing/readme.md @@ -24,7 +24,7 @@ Once parameter file is edited you can deploy it using [create-resources script]( i. e. if you are in windows, to deploy a Storage account in a new resourcegroup located in westus, go to `deploy\az` folder and type: ``` -create-resources.cmd marketing\deploystorage newResourceGroup -c westus +create-resources.cmd storage\marketing\deploystorage newResourceGroup -c westus ``` diff --git a/docker-compose-external.override.yml b/docker-compose-external.override.yml index 5a4957115..4637385a1 100644 --- a/docker-compose-external.override.yml +++ b/docker-compose-external.override.yml @@ -1,4 +1,4 @@ -version: '3.3' +version: '3.4' services: sql.data: diff --git a/docker-compose-external.yml b/docker-compose-external.yml index 43a1559be..22fe4ce89 100644 --- a/docker-compose-external.yml +++ b/docker-compose-external.yml @@ -1,4 +1,4 @@ -version: '3.3' +version: '3.4' services: sql.data: diff --git a/docker-compose-windows.prod.yml b/docker-compose-windows.prod.yml index c9e9825e3..ead977f29 100644 --- a/docker-compose-windows.prod.yml +++ b/docker-compose-windows.prod.yml @@ -1,4 +1,4 @@ -version: '3.3' +version: '3.4' # The Production docker-compose file has to have the external/real IPs or DNS names for the services # The ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP environment variable is taken, by default, from the ".env" file defined like: diff --git a/docker-compose-windows.yml b/docker-compose-windows.yml index 35f3ff7be..cec7323d1 100644 --- a/docker-compose-windows.yml +++ b/docker-compose-windows.yml @@ -1,4 +1,4 @@ -version: '3.3' +version: '3.4' services: basket.api: diff --git a/docker-compose.ci.build.yml b/docker-compose.ci.build.yml index e941c6ec1..747e8e583 100644 --- a/docker-compose.ci.build.yml +++ b/docker-compose.ci.build.yml @@ -1,4 +1,4 @@ -version: '3.3' +version: '3.4' services: ci-build: diff --git a/docker-compose.nobuild.yml b/docker-compose.nobuild.yml index bf1d9d24e..b2ebcf903 100644 --- a/docker-compose.nobuild.yml +++ b/docker-compose.nobuild.yml @@ -1,4 +1,4 @@ -version: '3.3' +version: '3.4' services: basket.api: diff --git a/docker-compose.override.windows.yml b/docker-compose.override.windows.yml index b4828607a..76ccda8b0 100644 --- a/docker-compose.override.windows.yml +++ b/docker-compose.override.windows.yml @@ -1,4 +1,4 @@ -version: '3.3' +version: '3.4' # ONLY NEEDED WHEN RUNNING WINDOWS CONTAINERS # diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 6cfe3a871..b8630ef97 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,4 +1,4 @@ -version: '3.3' +version: '3.4' # The Production docker-compose file has to have the external/real IPs or DNS names for the services # The ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP environment variable is taken, by default, from the ".env" file defined like: diff --git a/docs/Containerized-Docker-Application-Lifecycle-with-Microsoft-Platform-and-Tools-(eBook)_v1.1_Deprecated.pdf b/docs/Containerized-Docker-Application-Lifecycle-with-Microsoft-Platform-and-Tools-(eBook)_v1.1-Deprecated.pdf similarity index 100% rename from docs/Containerized-Docker-Application-Lifecycle-with-Microsoft-Platform-and-Tools-(eBook)_v1.1_Deprecated.pdf rename to docs/Containerized-Docker-Application-Lifecycle-with-Microsoft-Platform-and-Tools-(eBook)_v1.1-Deprecated.pdf diff --git a/docs/Microservicios-NET-Arquitectura-para-aplicaciones-NET-Contenerizadas-(Microsoft-for-Kindle)-es-ES.mobi b/docs/Microservicios-NET-Arquitectura-para-aplicaciones-NET-Contenerizadas-(Microsoft-for-Kindle)-es-ES.mobi new file mode 100644 index 000000000..1900fc281 Binary files /dev/null and b/docs/Microservicios-NET-Arquitectura-para-aplicaciones-NET-Contenerizadas-(Microsoft-for-Kindle)-es-ES.mobi differ diff --git a/docs/Microservicios-NET-Arquitectura-para-aplicaciones-NET-Contenerizadas-(Microsoft-for-eReader)-es-ES.epub b/docs/Microservicios-NET-Arquitectura-para-aplicaciones-NET-Contenerizadas-(Microsoft-for-eReader)-es-ES.epub new file mode 100644 index 000000000..3fbff2fa8 Binary files /dev/null and b/docs/Microservicios-NET-Arquitectura-para-aplicaciones-NET-Contenerizadas-(Microsoft-for-eReader)-es-ES.epub differ diff --git a/docs/NET-Microservices-Architecture-for-Containerized-NET-Applications-(Microsoft-eBook)-zh-CN-v2-older.pdf b/docs/NET-Microservices-Architecture-for-Containerized-NET-Applications-(Microsoft-eBook)-zh-CN-v2-older.pdf new file mode 100644 index 000000000..452ae61d0 Binary files /dev/null and b/docs/NET-Microservices-Architecture-for-Containerized-NET-Applications-(Microsoft-eBook)-zh-CN-v2-older.pdf differ diff --git a/docs/NET-Microservices-Architecture-for-Containerized-NET-Applications-(Microsoft-eBook)-zh-CN.pdf b/docs/NET-Microservices-Architecture-for-Containerized-NET-Applications-(Microsoft-eBook)-zh-CN.pdf index 452ae61d0..32c265632 100644 Binary files a/docs/NET-Microservices-Architecture-for-Containerized-NET-Applications-(Microsoft-eBook)-zh-CN.pdf and b/docs/NET-Microservices-Architecture-for-Containerized-NET-Applications-(Microsoft-eBook)-zh-CN.pdf differ diff --git a/docs/NET-Microservices-Architecture-for-Containerized-NET-Applications-(Microsoft-for-Kindle)-v1.mobi b/docs/NET-Microservices-Architecture-for-Containerized-NET-Applications-(Microsoft-for-Kindle)-v1.mobi new file mode 100644 index 000000000..728f15755 Binary files /dev/null and b/docs/NET-Microservices-Architecture-for-Containerized-NET-Applications-(Microsoft-for-Kindle)-v1.mobi differ diff --git a/docs/NET-Microservices-Architecture-for-Containerized-NET-Applications-(Microsoft-for-eReader)-v1.epub b/docs/NET-Microservices-Architecture-for-Containerized-NET-Applications-(Microsoft-for-eReader)-v1.epub new file mode 100644 index 000000000..5d4a8b491 Binary files /dev/null and b/docs/NET-Microservices-Architecture-for-Containerized-NET-Applications-(Microsoft-for-eReader)-v1.epub differ diff --git a/k8s/conf_cloud.yml b/k8s/conf_cloud.yml index 891de14bc..a914105ae 100644 --- a/k8s/conf_cloud.yml +++ b/k8s/conf_cloud.yml @@ -3,8 +3,8 @@ kind: ConfigMap metadata: name: externalcfg labels: - app: eshop -data: + app: eshop +data: # Basket.API entries basket__ConnectionString: REDIS CONNECTION STRING FOR BASKET # Catalog.API entries @@ -12,23 +12,23 @@ data: # Identity.API entries IdentitySqlDb: Identity SQL SERVER CONNECTION STRING (Server=xxxx;Intial Catalog=yyy;....) # Locations.API entries - LocationsBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure) + LocationsBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX for topic in case of using Azure) LocationsNoSqlDb: Locations MongoDb ConnectionString LocationsNoSqlDbName: Locations MongoDb database (LocationsDb) # Marketing.API entries - MarketingBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure) + MarketingBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX for topic in case of using Azure) MarketingNoSqlDb: Marketing MongoDb ConnectionString MarketingNoSqlDbName: Marketing MongoDb database (MarketingDb) MarketingSqlDb: Marketing SQL SERVER CONNECTION STRING (Server=xxxx;Intial Catalog=yyy;....) # Ordering.API entries - OrderingBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure) + OrderingBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX for topic in case of using Azure) OrderingSqlDb: Ordering SQL SERVER CONNECTION STRING (Server=xxxx;Intial Catalog=yyy;....) GracePeriodManager_GracePeriodTime: "1" GracePeriodManager_CheckUpdateTime: "15000" # Payment.API entries - PaymentBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure) + PaymentBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX for topic in case of using Azure) # Global entries all_UseAzureServiceBus: "TRUE" IF USE AZURE SB ("FALSE" FOR USING RABBITMQ) keystore: REDIS CONNECTION STRING FOR KEYSTORE all_EventBusConnection: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure) - all_InstrumentationKey: APPINSIGHTS KEY \ No newline at end of file + all_InstrumentationKey: APPINSIGHTS KEY diff --git a/k8s/gen-k8s-env-aks.ps1 b/k8s/gen-k8s-env-aks.ps1 index 1be5cd2c3..ef36a390d 100644 --- a/k8s/gen-k8s-env-aks.ps1 +++ b/k8s/gen-k8s-env-aks.ps1 @@ -22,10 +22,10 @@ if ($createAcr -eq $true) { Write-Host "Creating kubernetes orchestrator..." -ForegroundColor Yellow az aks create --resource-group=$resourceGroupName --name=$serviceName --generate-ssh-keys --node-count=$nodeCount --node-vm-size=$nodeVMSize -# Retrieve kubernetes cluster configuration and save it under ~/.kube/config +# Retrieve kubernetes cluster configuration and save it under ~/.kube/config az aks get-credentials --resource-group=$resourceGroupName --name=$serviceName if ($createAcr -eq $true) { # Show ACR credentials az acr credential show -n $registryName -} \ No newline at end of file +} diff --git a/src/BuildingBlocks/EventBus/EventBus/EventBus.csproj b/src/BuildingBlocks/EventBus/EventBus/EventBus.csproj index ac2d3783e..b219dcfa1 100644 --- a/src/BuildingBlocks/EventBus/EventBus/EventBus.csproj +++ b/src/BuildingBlocks/EventBus/EventBus/EventBus.csproj @@ -6,7 +6,7 @@ - + \ No newline at end of file diff --git a/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj b/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj index a7e31fcd7..d6c9fc8e2 100644 --- a/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj +++ b/src/BuildingBlocks/EventBus/EventBusRabbitMQ/EventBusRabbitMQ.csproj @@ -7,9 +7,10 @@ + - - + + diff --git a/src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj b/src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj index 17076b2f5..8e76a02db 100644 --- a/src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj +++ b/src/BuildingBlocks/EventBus/EventBusServiceBus/EventBusServiceBus.csproj @@ -8,6 +8,7 @@ + diff --git a/src/BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj b/src/BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj index 7e9b67fc0..d4f380a14 100644 --- a/src/BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj +++ b/src/BuildingBlocks/EventBus/IntegrationEventLogEF/IntegrationEventLogEF.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.AzureStorage/Microsoft.Extensions.HealthChecks.AzureStorage.csproj b/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.AzureStorage/Microsoft.Extensions.HealthChecks.AzureStorage.csproj index eaa067a54..007f66f65 100644 --- a/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.AzureStorage/Microsoft.Extensions.HealthChecks.AzureStorage.csproj +++ b/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks.AzureStorage/Microsoft.Extensions.HealthChecks.AzureStorage.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj b/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj index 1b642d062..6c102c33d 100644 --- a/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj +++ b/src/BuildingBlocks/HealthChecks/src/Microsoft.Extensions.HealthChecks/Microsoft.Extensions.HealthChecks.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/BuildingBlocks/Resilience/Resilience.Http/Resilience.Http.csproj b/src/BuildingBlocks/Resilience/Resilience.Http/Resilience.Http.csproj index b166812cb..276c1a23f 100644 --- a/src/BuildingBlocks/Resilience/Resilience.Http/Resilience.Http.csproj +++ b/src/BuildingBlocks/Resilience/Resilience.Http/Resilience.Http.csproj @@ -8,8 +8,8 @@ - - + + \ No newline at end of file diff --git a/src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj b/src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj index c1240c521..6a6632379 100644 --- a/src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj +++ b/src/BuildingBlocks/WebHostCustomization/WebHost.Customization/WebHost.Customization.csproj @@ -5,8 +5,8 @@ - - + + diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Extensions/ObservableExtension.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Extensions/ObservableExtension.cs index ad10bd941..800f9a031 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Extensions/ObservableExtension.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Extensions/ObservableExtension.cs @@ -15,7 +15,6 @@ namespace eShopOnContainers.Core.Extensions } return collection; - } } } \ No newline at end of file diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/ISettingsService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/ISettingsService.cs index 5e2732bf9..69ede7b72 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/ISettingsService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/ISettingsService.cs @@ -1,4 +1,6 @@ -namespace eShopOnContainers.Core.Services.Settings +using System.Threading.Tasks; + +namespace eShopOnContainers.Core.Services.Settings { public interface ISettingsService { @@ -10,5 +12,10 @@ string Latitude { get; set; } string Longitude { get; set; } bool AllowGpsLocation { get; set; } + + bool GetValueOrDefault(string key, bool defaultValue); + string GetValueOrDefault(string key, string defaultValue); + Task AddOrUpdateValue(string key, bool value); + Task AddOrUpdateValue(string key, string value); } } diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/ISettingsServiceImplementation.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/ISettingsServiceImplementation.cs deleted file mode 100644 index ef9d14ed6..000000000 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/ISettingsServiceImplementation.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace eShopOnContainers.Core.Services.Settings -{ - public interface ISettingsServiceImplementation - { - bool GetValueOrDefault(string key, bool defaultValue); - string GetValueOrDefault(string key, string defaultValue); - - bool AddOrUpdateValue(string key, bool value); - bool AddOrUpdateValue(string key, string value); - - void Remove(string key); - } -} diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/SettingsService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/SettingsService.cs index a13f53187..ca3e03c04 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/SettingsService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Core/Services/Settings/SettingsService.cs @@ -1,21 +1,11 @@ -using eShopOnContainers.Core.Services.Dependency; +using System; +using System.Threading.Tasks; +using Xamarin.Forms; namespace eShopOnContainers.Core.Services.Settings { public class SettingsService : ISettingsService { - private readonly ISettingsServiceImplementation _settingsService; - - ISettingsServiceImplementation AppSettings - { - get { return _settingsService; } - } - - public SettingsService(IDependencyService dependencyService) - { - _settingsService = dependencyService.Get(); - } - #region Setting Constants private const string AccessToken = "access_token"; @@ -37,52 +27,113 @@ namespace eShopOnContainers.Core.Services.Settings #endregion + #region Settings Properties + public string AuthAccessToken { - get => AppSettings.GetValueOrDefault(AccessToken, AccessTokenDefault); - set => AppSettings.AddOrUpdateValue(AccessToken, value); + get => GetValueOrDefault(AccessToken, AccessTokenDefault); + set => AddOrUpdateValue(AccessToken, value); } public string AuthIdToken { - get => AppSettings.GetValueOrDefault(IdToken, IdTokenDefault); - set => AppSettings.AddOrUpdateValue(IdToken, value); + get => GetValueOrDefault(IdToken, IdTokenDefault); + set => AddOrUpdateValue(IdToken, value); } public bool UseMocks { - get => AppSettings.GetValueOrDefault(IdUseMocks, UseMocksDefault); - set => AppSettings.AddOrUpdateValue(IdUseMocks, value); + get => GetValueOrDefault(IdUseMocks, UseMocksDefault); + set => AddOrUpdateValue(IdUseMocks, value); } public string UrlBase { - get => AppSettings.GetValueOrDefault(IdUrlBase, UrlBaseDefault); - set => AppSettings.AddOrUpdateValue(IdUrlBase, value); + get => GetValueOrDefault(IdUrlBase, UrlBaseDefault); + set => AddOrUpdateValue(IdUrlBase, value); } public bool UseFakeLocation { - get => AppSettings.GetValueOrDefault(IdUseFakeLocation, UseFakeLocationDefault); - set => AppSettings.AddOrUpdateValue(IdUseFakeLocation, value); + get => GetValueOrDefault(IdUseFakeLocation, UseFakeLocationDefault); + set => AddOrUpdateValue(IdUseFakeLocation, value); } public string Latitude { - get => AppSettings.GetValueOrDefault(IdLatitude, FakeLatitudeDefault.ToString()); - set => AppSettings.AddOrUpdateValue(IdLatitude, value); + get => GetValueOrDefault(IdLatitude, FakeLatitudeDefault.ToString()); + set => AddOrUpdateValue(IdLatitude, value); } public string Longitude { - get => AppSettings.GetValueOrDefault(IdLongitude, FakeLongitudeDefault.ToString()); - set => AppSettings.AddOrUpdateValue(IdLongitude, value); + get => GetValueOrDefault(IdLongitude, FakeLongitudeDefault.ToString()); + set => AddOrUpdateValue(IdLongitude, value); } public bool AllowGpsLocation { - get => AppSettings.GetValueOrDefault(IdAllowGpsLocation, AllowGpsLocationDefault); - set => AppSettings.AddOrUpdateValue(IdAllowGpsLocation, value); + get => GetValueOrDefault(IdAllowGpsLocation, AllowGpsLocationDefault); + set => AddOrUpdateValue(IdAllowGpsLocation, value); } + + #endregion + + #region Public Methods + + public Task AddOrUpdateValue(string key, bool value) => AddOrUpdateValueInternal(key, value); + public Task AddOrUpdateValue(string key, string value) => AddOrUpdateValueInternal(key, value); + public bool GetValueOrDefault(string key, bool defaultValue) => GetValueOrDefaultInternal(key, defaultValue); + public string GetValueOrDefault(string key, string defaultValue) => GetValueOrDefaultInternal(key, defaultValue); + + #endregion + + #region Internal Implementation + + async Task AddOrUpdateValueInternal(string key, T value) + { + if (value == null) + { + await Remove(key); + } + + Application.Current.Properties[key] = value; + try + { + await Application.Current.SavePropertiesAsync(); + } + catch (Exception ex) + { + Console.WriteLine("Unable to save: " + key, " Message: " + ex.Message); + } + } + + T GetValueOrDefaultInternal(string key, T defaultValue = default(T)) + { + object value = null; + if (Application.Current.Properties.ContainsKey(key)) + { + value = Application.Current.Properties[key]; + } + return null != value ? (T)value : defaultValue; + } + + async Task Remove(string key) + { + try + { + if (Application.Current.Properties[key] != null) + { + Application.Current.Properties.Remove(key); + await Application.Current.SavePropertiesAsync(); + } + } + catch (Exception ex) + { + Console.WriteLine("Unable to remove: " + key, " Message: " + ex.Message); + } + } + + #endregion } } \ No newline at end of file diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Extensions/LocationExtensions.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Extensions/LocationExtensions.cs index 41ea2ad3e..031c186aa 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Extensions/LocationExtensions.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Extensions/LocationExtensions.cs @@ -32,7 +32,7 @@ namespace eShopOnContainers.Droid.Extensions { return new DateTimeOffset(Epoch.AddMilliseconds(location.Time)); } - catch (Exception e) + catch (Exception) { return new DateTimeOffset(Epoch); } diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Services/SettingsServiceImplementation.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Services/SettingsServiceImplementation.cs deleted file mode 100644 index 7cdce4555..000000000 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/Services/SettingsServiceImplementation.cs +++ /dev/null @@ -1,149 +0,0 @@ -using Android.App; -using Android.Content; -using Android.Preferences; -using eShopOnContainers.Core.Services.Settings; -using eShopOnContainers.Droid.Services; -using System; - -[assembly: Xamarin.Forms.Dependency(typeof(SettingsServiceImplementation))] -namespace eShopOnContainers.Droid.Services -{ - public class SettingsServiceImplementation : ISettingsServiceImplementation - { - #region Internal Implementation - - readonly object _locker = new object(); - - ISharedPreferences GetSharedPreference() - { - return PreferenceManager.GetDefaultSharedPreferences(Application.Context); - } - - bool AddOrUpdateValueInternal(string key, T value) - { - if (Application.Context == null) - return false; - - if (value == null) - { - Remove(key); - return true; - } - - var type = typeof(T); - if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) - { - type = Nullable.GetUnderlyingType(type); - } - var typeCode = Type.GetTypeCode(type); - - lock (_locker) - { - using (var sharedPrefs = GetSharedPreference()) - { - using (var editor = sharedPrefs.Edit()) - { - switch (typeCode) - { - case TypeCode.Boolean: - editor.PutBoolean(key, Convert.ToBoolean(value)); - break; - case TypeCode.String: - editor.PutString(key, Convert.ToString(value)); - break; - default: - throw new ArgumentException($"Value of type {typeCode} is not supported."); - } - editor.Commit(); - } - } - } - return true; - } - - T GetValueOrDefaultInternal(string key, T defaultValue = default(T)) - { - if (Application.Context == null) - return defaultValue; - - if (!Contains(key)) - return defaultValue; - - lock (_locker) - { - using (var sharedPrefs = GetSharedPreference()) - { - var type = typeof(T); - if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) - { - type = Nullable.GetUnderlyingType(type); - } - - object value = null; - var typeCode = Type.GetTypeCode(type); - switch (typeCode) - { - case TypeCode.Boolean: - value = sharedPrefs.GetBoolean(key, Convert.ToBoolean(defaultValue)); - break; - case TypeCode.String: - value = sharedPrefs.GetString(key, Convert.ToString(defaultValue)); - break; - default: - throw new ArgumentException($"Value of type {typeCode} is not supported."); - } - - return null != value ? (T)value : defaultValue; - } - } - } - - bool Contains(string key) - { - if (Application.Context == null) - return false; - - lock (_locker) - { - using (var sharedPrefs = GetSharedPreference()) - { - if (sharedPrefs == null) - return false; - return sharedPrefs.Contains(key); - } - } - } - - #endregion - - #region ISettingsServiceImplementation - - public bool AddOrUpdateValue(string key, bool value) => AddOrUpdateValueInternal(key, value); - - public bool AddOrUpdateValue(string key, string value) => AddOrUpdateValueInternal(key, value); - - public bool GetValueOrDefault(string key, bool defaultValue) => GetValueOrDefaultInternal(key, defaultValue); - - public string GetValueOrDefault(string key, string defaultValue) => GetValueOrDefaultInternal(key, defaultValue); - - public void Remove(string key) - { - if (Application.Context == null) - return; - - lock (_locker) - { - using (var sharedPrefs = GetSharedPreference()) - { - using (var editor = sharedPrefs.Edit()) - { - editor.Remove(key); - editor.Commit(); - } - } - } - } - - #endregion - } -} diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj index 7d699f9d2..92e2df581 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj @@ -19,7 +19,7 @@ Off Properties\AndroidManifest.xml true - v8.0 + v8.1 armeabi,armeabi-v7a,x86 @@ -211,7 +211,6 @@ - diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj b/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj index 4a83a29a8..250d836a7 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj @@ -1,232 +1,232 @@  - - - - Debug - iPhoneSimulator - {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3} - {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Exe - eShopOnContainers.TestRunner.iOS - Resources - eShopOnContainersTestRunneriOS - - - - - true - full - false - bin\iPhoneSimulator\Debug - DEBUG - prompt - 4 - false - x86_64 - None - True - False - False - False - False - False - True - Default - HttpClientHandler - False - - - false - none - true - bin\iPhoneSimulator\Release - prompt - 4 - None - x86_64 - false - - - true - full - false - bin\iPhone\Debug - DEBUG - prompt - 4 - false - ARMv7, ARM64 - Entitlements.plist - iPhone Developer - true - None - - - false - none - true - bin\iPhone\Release - prompt - 4 - Entitlements.plist - ARMv7, ARM64 - false - iPhone Developer - - - none - True - bin\iPhone\Ad-Hoc - prompt - 4 - False - ARMv7, ARM64 - Entitlements.plist - True - Automatic:AdHoc - iPhone Distribution - - - none - True - bin\iPhone\AppStore - prompt - 4 - False - ARMv7, ARM64 - Entitlements.plist - Automatic:AppStore - iPhone Distribution - - - - - - - - - - - - - - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll - - - - - - ..\..\..\..\packages\xunit.runner.devices.2.3.3\lib\xamarinios10\xunit.runner.devices.dll - - - ..\..\..\..\packages\xunit.runner.devices.2.3.3\lib\xamarinios10\xunit.runner.utility.netstandard15.dll - - - ..\..\..\..\packages\xunit.abstractions.2.0.1\lib\netstandard1.0\xunit.abstractions.dll - - - ..\..\..\..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll - - - ..\..\..\..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll - - - ..\..\..\..\packages\xunit.extensibility.execution.2.3.1\lib\netstandard1.1\xunit.execution.dotnet.dll - - - - ..\..\..\..\packages\Newtonsoft.Json.10.0.3\lib\netstandard1.3\Newtonsoft.Json.dll - - - ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.dll - - - ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.iOS.dll - - - ..\..\..\..\packages\IdentityModel.3.0.0\lib\netstandard2.0\IdentityModel.dll - - - ..\..\..\..\packages\Acr.Support.2.1.0\lib\Xamarin.iOS10\Acr.Support.iOS.dll - - - ..\..\..\..\packages\BTProgressHUD.1.2.0.5\lib\Xamarin.iOS10\BTProgressHUD.dll - - - ..\..\..\..\packages\Splat.2.0.0\lib\Xamarin.iOS10\Splat.dll - - - ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.dll - - - ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.Interface.dll - - - ..\..\..\..\packages\WebP.Touch.1.0.7\lib\Xamarin.iOS10\WebP.Touch.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Platform.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.Touch.dll - - - ..\..\..\..\packages\PInvoke.Windows.Core.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Windows.Core.dll - - - ..\..\..\..\packages\PInvoke.Kernel32.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Kernel32.dll - - - ..\..\..\..\packages\PInvoke.BCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.BCrypt.dll - - - ..\..\..\..\packages\PInvoke.NCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.NCrypt.dll - - - ..\..\..\..\packages\Validation.2.2.8\lib\dotnet\Validation.dll - - - ..\..\..\..\packages\PCLCrypto.2.0.147\lib\xamarinios10\PCLCrypto.dll - - - - - - - - {FDD910BC-DF0F-483D-B7D5-C7D831855172} - eShopOnContainers.UnitTests - - - - - - + + - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + Debug + iPhoneSimulator + {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3} + {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Exe + eShopOnContainers.TestRunner.iOS + Resources + eShopOnContainersTestRunneriOS + + + true - - - - - - + + true + full + false + bin\iPhoneSimulator\Debug + DEBUG + prompt + 4 + false + x86_64 + None + True + False + False + False + False + False + True + Default + HttpClientHandler + False + + + false + none + true + bin\iPhoneSimulator\Release + prompt + 4 + None + x86_64 + false + + + true + full + false + bin\iPhone\Debug + DEBUG + prompt + 4 + false + ARMv7, ARM64 + Entitlements.plist + iPhone Developer + true + None + + + false + none + true + bin\iPhone\Release + prompt + 4 + Entitlements.plist + ARMv7, ARM64 + false + iPhone Developer + + + none + True + bin\iPhone\Ad-Hoc + prompt + 4 + False + ARMv7, ARM64 + Entitlements.plist + True + Automatic:AdHoc + iPhone Distribution + + + none + True + bin\iPhone\AppStore + prompt + 4 + False + ARMv7, ARM64 + Entitlements.plist + Automatic:AppStore + iPhone Distribution + + + + + + + + + + + + + + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll + + + + + + ..\..\..\..\packages\xunit.runner.devices.2.3.3\lib\xamarinios10\xunit.runner.devices.dll + + + ..\..\..\..\packages\xunit.runner.devices.2.3.3\lib\xamarinios10\xunit.runner.utility.netstandard15.dll + + + ..\..\..\..\packages\xunit.abstractions.2.0.1\lib\netstandard1.0\xunit.abstractions.dll + + + ..\..\..\..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll + + + ..\..\..\..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll + + + ..\..\..\..\packages\xunit.extensibility.execution.2.3.1\lib\netstandard1.1\xunit.execution.dotnet.dll + + + ..\..\..\..\packages\Newtonsoft.Json.10.0.3\lib\netstandard1.3\Newtonsoft.Json.dll + + + ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.dll + + + ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.iOS.dll + + + ..\..\..\..\packages\IdentityModel.3.0.0\lib\netstandard2.0\IdentityModel.dll + + + ..\..\..\..\packages\Acr.Support.2.1.0\lib\Xamarin.iOS10\Acr.Support.iOS.dll + + + ..\..\..\..\packages\BTProgressHUD.1.2.0.5\lib\Xamarin.iOS10\BTProgressHUD.dll + + + ..\..\..\..\packages\Splat.2.0.0\lib\Xamarin.iOS10\Splat.dll + + + ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.dll + + + ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.Interface.dll + + + ..\..\..\..\packages\WebP.Touch.1.0.7\lib\Xamarin.iOS10\WebP.Touch.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Platform.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.Touch.dll + + + ..\..\..\..\packages\PInvoke.Windows.Core.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Windows.Core.dll + + + ..\..\..\..\packages\PInvoke.Kernel32.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Kernel32.dll + + + ..\..\..\..\packages\PInvoke.BCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.BCrypt.dll + + + ..\..\..\..\packages\PInvoke.NCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.NCrypt.dll + + + ..\..\..\..\packages\Validation.2.2.8\lib\dotnet\Validation.dll + + + ..\..\..\..\packages\PCLCrypto.2.0.147\lib\xamarinios10\PCLCrypto.dll + + + + + + + + {FDD910BC-DF0F-483D-B7D5-C7D831855172} + eShopOnContainers.UnitTests + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Mocks/MockSettingsService.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Mocks/MockSettingsService.cs index 23e1cedc5..37bfc125f 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Mocks/MockSettingsService.cs +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.UnitTests/Mocks/MockSettingsService.cs @@ -1,65 +1,110 @@ using eShopOnContainers.Core.Services.Settings; -using System; +using System.Collections.Generic; +using System.Threading.Tasks; namespace eShopOnContainers.UnitTests.Mocks { public class MockSettingsService : ISettingsService { - string _accessTokenDefault = string.Empty; - string _idTokenDefault = string.Empty; - bool _useMocksDefault = true; - string _urlBaseDefault = "https://13.88.8.119"; - bool _useFakeLocationDefault = false; - bool _allowGpsLocationDefault = false; - double _fakeLatitudeDefault = 47.604610d; - double _fakeLongitudeDefault = -122.315752d; + IDictionary _settings = new Dictionary(); + + const string AccessToken = "access_token"; + const string IdToken = "id_token"; + const string IdUseMocks = "use_mocks"; + const string IdUrlBase = "url_base"; + const string IdUseFakeLocation = "use_fake_location"; + const string IdLatitude = "latitude"; + const string IdLongitude = "longitude"; + const string IdAllowGpsLocation = "allow_gps_location"; + readonly string AccessTokenDefault = string.Empty; + readonly string IdTokenDefault = string.Empty; + readonly bool UseMocksDefault = true; + readonly bool UseFakeLocationDefault = false; + readonly bool AllowGpsLocationDefault = false; + readonly double FakeLatitudeDefault = 47.604610d; + readonly double FakeLongitudeDefault = -122.315752d; + readonly string UrlBaseDefault = "https://13.88.8.119"; public string AuthAccessToken { - get { return _accessTokenDefault; } - set { _accessTokenDefault = value; } + get => GetValueOrDefault(AccessToken, AccessTokenDefault); + set => AddOrUpdateValue(AccessToken, value); } public string AuthIdToken { - get { return _idTokenDefault; } - set { _idTokenDefault = value; } + get => GetValueOrDefault(IdToken, IdTokenDefault); + set => AddOrUpdateValue(IdToken, value); } public bool UseMocks { - get { return _useMocksDefault; } - set { _useMocksDefault = value; } + get => GetValueOrDefault(IdUseMocks, UseMocksDefault); + set => AddOrUpdateValue(IdUseMocks, value); } public string UrlBase { - get { return _urlBaseDefault; } - set { _urlBaseDefault = value; } + get => GetValueOrDefault(IdUrlBase, UrlBaseDefault); + set => AddOrUpdateValue(IdUrlBase, value); } public bool UseFakeLocation { - get { return _useFakeLocationDefault; } - set { _useFakeLocationDefault = value; } + get => GetValueOrDefault(IdUseFakeLocation, UseFakeLocationDefault); + set => AddOrUpdateValue(IdUseFakeLocation, value); } public string Latitude { - get { return _fakeLatitudeDefault.ToString(); } - set { _fakeLatitudeDefault = Convert.ToDouble(value); } + get => GetValueOrDefault(IdLatitude, FakeLatitudeDefault.ToString()); + set => AddOrUpdateValue(IdLatitude, value); } public string Longitude { - get { return _fakeLongitudeDefault.ToString(); } - set { _fakeLongitudeDefault = Convert.ToDouble(value); } + get => GetValueOrDefault(IdLongitude, FakeLongitudeDefault.ToString()); + set => AddOrUpdateValue(IdLongitude, value); } public bool AllowGpsLocation { - get { return _allowGpsLocationDefault; } - set { _allowGpsLocationDefault = value; } + get => GetValueOrDefault(IdAllowGpsLocation, AllowGpsLocationDefault); + set => AddOrUpdateValue(IdAllowGpsLocation, value); + } + + public Task AddOrUpdateValue(string key, bool value) => AddOrUpdateValueInternal(key, value); + public Task AddOrUpdateValue(string key, string value) => AddOrUpdateValueInternal(key, value); + public bool GetValueOrDefault(string key, bool defaultValue) => GetValueOrDefaultInternal(key, defaultValue); + public string GetValueOrDefault(string key, string defaultValue) => GetValueOrDefaultInternal(key, defaultValue); + + Task AddOrUpdateValueInternal(string key, T value) + { + if (value == null) + { + Remove(key); + } + + _settings[key] = value; + return Task.Delay(10); + } + + T GetValueOrDefaultInternal(string key, T defaultValue = default(T)) + { + object value = null; + if (_settings.ContainsKey(key)) + { + value = _settings[key]; + } + return null != value ? (T)value : defaultValue; + } + + void Remove(string key) + { + if (_settings[key] != null) + { + _settings.Remove(key); + } } } } diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Windows/Services/SettingsServiceImplementation.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.Windows/Services/SettingsServiceImplementation.cs deleted file mode 100644 index e13fafd9f..000000000 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Windows/Services/SettingsServiceImplementation.cs +++ /dev/null @@ -1,99 +0,0 @@ -using eShopOnContainers.Core.Services.Settings; -using eShopOnContainers.Windows.Services; -using Windows.Storage; - -[assembly: Xamarin.Forms.Dependency(typeof(SettingsServiceImplementation))] -namespace eShopOnContainers.Windows.Services -{ - public class SettingsServiceImplementation : ISettingsServiceImplementation - { - #region Internal Implementation - - readonly object _locker = new object(); - - ApplicationDataContainer GetAppSettings() - { - return ApplicationData.Current.LocalSettings; - } - - bool AddOrUpdateValueInternal(string key, T value) - { - bool valueChanged = false; - - if (value == null) - { - Remove(key); - return true; - } - - lock (_locker) - { - var settings = GetAppSettings(); - if (settings.Values.ContainsKey(key)) - { - if (settings.Values[key] != (object)value) - { - settings.Values[key] = value; - valueChanged = true; - } - } - else - { - settings.Values[key] = value; - valueChanged = true; - } - } - - return valueChanged; - } - - T GetValueOrDefaultInternal(string key, T defaultValue = default(T)) - { - object value; - - lock (_locker) - { - var settings = GetAppSettings(); - if (settings.Values.ContainsKey(key)) - { - var tempValue = settings.Values[key]; - if (tempValue != null) - value = (T)tempValue; - else - value = defaultValue; - } - else - { - value = defaultValue; - } - } - return null != value ? (T)value : defaultValue; - } - - #endregion - - #region ISettingsServiceImplementation - - public bool AddOrUpdateValue(string key, bool value) => AddOrUpdateValueInternal(key, value); - - public bool AddOrUpdateValue(string key, string value) => AddOrUpdateValueInternal(key, value); - - public bool GetValueOrDefault(string key, bool defaultValue) => GetValueOrDefaultInternal(key, defaultValue); - - public string GetValueOrDefault(string key, string defaultValue) => GetValueOrDefaultInternal(key, defaultValue); - - public void Remove(string key) - { - lock (_locker) - { - var settings = GetAppSettings(); - if (settings.Values.ContainsKey(key)) - { - settings.Values.Remove(key); - } - } - } - - #endregion - } -} diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Windows/eShopOnContainers.Windows.csproj b/src/Mobile/eShopOnContainers/eShopOnContainers.Windows/eShopOnContainers.Windows.csproj index b879d31c6..9a1a2d108 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Windows/eShopOnContainers.Windows.csproj +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Windows/eShopOnContainers.Windows.csproj @@ -123,7 +123,6 @@ - diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.iOS/Services/SettingsServiceImplementation.cs b/src/Mobile/eShopOnContainers/eShopOnContainers.iOS/Services/SettingsServiceImplementation.cs deleted file mode 100644 index ee17b8ff7..000000000 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.iOS/Services/SettingsServiceImplementation.cs +++ /dev/null @@ -1,128 +0,0 @@ -using eShopOnContainers.Core.Services.Settings; -using eShopOnContainers.iOS.Services; -using Foundation; -using System; - -[assembly: Xamarin.Forms.Dependency(typeof(SettingsServiceImplementation))] -namespace eShopOnContainers.iOS.Services -{ - public class SettingsServiceImplementation : ISettingsServiceImplementation - { - #region Internal Implementation - - readonly object _locker = new object(); - - NSUserDefaults GetUserDefaults() => NSUserDefaults.StandardUserDefaults; - - bool AddOrUpdateValueInternal(string key, T value) - { - if (value == null) - { - Remove(key); - return true; - } - - var type = typeof(T); - if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) - { - type = Nullable.GetUnderlyingType(type); - } - var typeCode = Type.GetTypeCode(type); - - lock (_locker) - { - var defaults = GetUserDefaults(); - switch (typeCode) - { - case TypeCode.Boolean: - defaults.SetBool(Convert.ToBoolean(value), key); - break; - case TypeCode.String: - defaults.SetString(Convert.ToString(value), key); - break; - default: - throw new ArgumentException($"Value of type {typeCode} is unsupported."); - } - - try - { - defaults.Synchronize(); - } - catch (Exception ex) - { - Console.WriteLine("Unable to save: " + key, " Message: " + ex.Message); - } - } - return true; - } - - T GetValueOrDefaultInternal(string key, T defaultValue = default(T)) - { - lock (_locker) - { - var defaults = GetUserDefaults(); - - if (defaults[key] == null) - { - return defaultValue; - } - - var type = typeof(T); - if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) - { - type = Nullable.GetUnderlyingType(type); - } - - object value = null; - var typeCode = Type.GetTypeCode(type); - switch (typeCode) - { - case TypeCode.Boolean: - value = defaults.BoolForKey(key); - break; - case TypeCode.String: - value = defaults.StringForKey(key); - break; - default: - throw new ArgumentException($"Value of type {typeCode} is unsupported."); - } - - return null != value ? (T)value : defaultValue; - } - } - - #endregion - - #region ISettingsServiceImplementation - - public bool AddOrUpdateValue(string key, bool value) => AddOrUpdateValueInternal(key, value); - - public bool AddOrUpdateValue(string key, string value) => AddOrUpdateValueInternal(key, value); - - public bool GetValueOrDefault(string key, bool defaultValue) => GetValueOrDefaultInternal(key, defaultValue); - - public string GetValueOrDefault(string key, string defaultValue) => GetValueOrDefaultInternal(key, defaultValue); - - public void Remove(string key) - { - lock (_locker) - { - var defaults = GetUserDefaults(); - try - { - if (defaults[key] != null) - { - defaults.RemoveObject(key); - defaults.Synchronize(); - } - } - catch (Exception ex) - { - Console.WriteLine("Unable to remove: " + key, " Message: " + ex.Message); - } - } - } - - #endregion - } -} diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.iOS/eShopOnContainers.iOS.csproj b/src/Mobile/eShopOnContainers/eShopOnContainers.iOS/eShopOnContainers.iOS.csproj index 6ea0a4465..3d18f3a5c 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.iOS/eShopOnContainers.iOS.csproj +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.iOS/eShopOnContainers.iOS.csproj @@ -1,429 +1,428 @@  - - - Debug - iPhoneSimulator - 8.0.30703 - 2.0 - {6EEB23DC-7063-4444-9AF8-90DF24F549C0} - {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Exe - eShopOnContainers.iOS - Resources - eShopOnContainersiOS - - - true - - - true - full - false - bin\iPhoneSimulator\Debug - DEBUG - prompt - 4 - false - i386, x86_64 - None - True - False - False - False - False - False - True - Default - HttpClientHandler - False - - - none - true - bin\iPhoneSimulator\Release - prompt - 4 - None - i386, x86_64 - false - - - true - full - false - bin\iPhone\Debug - DEBUG - prompt - 4 - false - ARMv7, ARM64 - iPhone Developer - true - Entitlements.plist - None - - - none - true - bin\iPhone\Release - prompt - 4 - ARMv7, ARM64 - false - iPhone Developer - Entitlements.plist - - - none - True - bin\iPhone\Ad-Hoc - prompt - 4 - False - ARMv7, ARM64 - True - Automatic:AdHoc - iPhone Distribution - Entitlements.plist - - - none - True - bin\iPhone\AppStore - prompt - 4 - False - ARMv7, ARM64 - Automatic:AppStore - iPhone Distribution - Entitlements.plist - - - - - - - Resources\fonts\Montserrat-Bold.ttf - - - Resources\fonts\Montserrat-Regular.ttf - - - Resources\fonts\SourceSansPro-Regular.ttf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll - - - ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll - - - ..\..\..\..\packages\WebP.Touch.1.0.7\lib\Xamarin.iOS10\WebP.Touch.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Platform.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.dll - - - ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.Touch.dll - - - ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.dll - - - ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.iOS.dll - - - ..\..\..\..\packages\Xam.Plugins.Settings.3.1.1\lib\Xamarin.iOS10\Plugin.Settings.Abstractions.dll - - - ..\..\..\..\packages\Xam.Plugins.Settings.3.1.1\lib\Xamarin.iOS10\Plugin.Settings.dll - - - - ..\..\..\..\packages\Newtonsoft.Json.10.0.3\lib\netstandard1.3\Newtonsoft.Json.dll - - - ..\..\..\..\packages\Acr.Support.2.1.0\lib\Xamarin.iOS10\Acr.Support.iOS.dll - - - ..\..\..\..\packages\BTProgressHUD.1.2.0.5\lib\Xamarin.iOS10\BTProgressHUD.dll - - - ..\..\..\..\packages\Splat.2.0.0\lib\Xamarin.iOS10\Splat.dll - - - ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.dll - - - ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.Interface.dll - - - ..\..\..\..\packages\PInvoke.Windows.Core.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Windows.Core.dll - - - ..\..\..\..\packages\PInvoke.Kernel32.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Kernel32.dll - - - ..\..\..\..\packages\PInvoke.BCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.BCrypt.dll - - - ..\..\..\..\packages\PInvoke.NCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.NCrypt.dll - - - ..\..\..\..\packages\Validation.2.2.8\lib\dotnet\Validation.dll - - - ..\..\..\..\packages\PCLCrypto.2.0.147\lib\xamarinios10\PCLCrypto.dll - - - ..\..\..\..\packages\IdentityModel.3.0.0\lib\netstandard2.0\IdentityModel.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {76C5F2A7-6CD5-49EA-9F33-EC44DE6539C7} - eShopOnContainers.Core - - - - - - - - - + - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + Debug + iPhoneSimulator + 8.0.30703 + 2.0 + {6EEB23DC-7063-4444-9AF8-90DF24F549C0} + {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Exe + eShopOnContainers.iOS + Resources + eShopOnContainersiOS + + + true + true - - - + + true + full + false + bin\iPhoneSimulator\Debug + DEBUG + prompt + 4 + false + i386, x86_64 + None + True + False + False + False + False + False + True + Default + HttpClientHandler + False + + + none + true + bin\iPhoneSimulator\Release + prompt + 4 + None + i386, x86_64 + false + + + true + full + false + bin\iPhone\Debug + DEBUG + prompt + 4 + false + ARMv7, ARM64 + iPhone Developer + true + Entitlements.plist + None + + + none + true + bin\iPhone\Release + prompt + 4 + ARMv7, ARM64 + false + iPhone Developer + Entitlements.plist + + + none + True + bin\iPhone\Ad-Hoc + prompt + 4 + False + ARMv7, ARM64 + True + Automatic:AdHoc + iPhone Distribution + Entitlements.plist + + + none + True + bin\iPhone\AppStore + prompt + 4 + False + ARMv7, ARM64 + Automatic:AppStore + iPhone Distribution + Entitlements.plist + + + + + + + Resources\fonts\Montserrat-Bold.ttf + + + Resources\fonts\Montserrat-Regular.ttf + + + Resources\fonts\SourceSansPro-Regular.ttf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll + + + ..\..\..\..\packages\Xamarin.Forms.2.5.0.122203\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll + + + ..\..\..\..\packages\WebP.Touch.1.0.7\lib\Xamarin.iOS10\WebP.Touch.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Platform.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.dll + + + ..\..\..\..\packages\Xamarin.FFImageLoading.Forms.2.3.4\lib\Xamarin.iOS10\FFImageLoading.Forms.Touch.dll + + + ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.dll + + + ..\..\..\..\packages\SlideOverKit.2.1.5\lib\Xamarin.iOS10\SlideOverKit.iOS.dll + + + ..\..\..\..\packages\Xam.Plugins.Settings.3.1.1\lib\Xamarin.iOS10\Plugin.Settings.Abstractions.dll + + + ..\..\..\..\packages\Xam.Plugins.Settings.3.1.1\lib\Xamarin.iOS10\Plugin.Settings.dll + + + ..\..\..\..\packages\Newtonsoft.Json.10.0.3\lib\netstandard1.3\Newtonsoft.Json.dll + + + ..\..\..\..\packages\Acr.Support.2.1.0\lib\Xamarin.iOS10\Acr.Support.iOS.dll + + + ..\..\..\..\packages\BTProgressHUD.1.2.0.5\lib\Xamarin.iOS10\BTProgressHUD.dll + + + ..\..\..\..\packages\Splat.2.0.0\lib\Xamarin.iOS10\Splat.dll + + + ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.dll + + + ..\..\..\..\packages\Acr.UserDialogs.6.5.1\lib\Xamarin.iOS10\Acr.UserDialogs.Interface.dll + + + ..\..\..\..\packages\PInvoke.Windows.Core.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Windows.Core.dll + + + ..\..\..\..\packages\PInvoke.Kernel32.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.Kernel32.dll + + + ..\..\..\..\packages\PInvoke.BCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.BCrypt.dll + + + ..\..\..\..\packages\PInvoke.NCrypt.0.3.2\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\PInvoke.NCrypt.dll + + + ..\..\..\..\packages\Validation.2.2.8\lib\dotnet\Validation.dll + + + ..\..\..\..\packages\PCLCrypto.2.0.147\lib\xamarinios10\PCLCrypto.dll + + + ..\..\..\..\packages\IdentityModel.3.0.0\lib\netstandard2.0\IdentityModel.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {76C5F2A7-6CD5-49EA-9F33-EC44DE6539C7} + eShopOnContainers.Core + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/src/Services/Basket/Basket.API/Basket.API.csproj b/src/Services/Basket/Basket.API/Basket.API.csproj index a613151e7..d7ffa46b8 100644 --- a/src/Services/Basket/Basket.API/Basket.API.csproj +++ b/src/Services/Basket/Basket.API/Basket.API.csproj @@ -13,13 +13,13 @@ - - - + + + - - - + + + diff --git a/src/Services/Basket/Basket.API/Dockerfile b/src/Services/Basket/Basket.API/Dockerfile index 22f0c6486..03a967a72 100644 --- a/src/Services/Basket/Basket.API/Dockerfile +++ b/src/Services/Basket/Basket.API/Dockerfile @@ -1,8 +1,8 @@ -FROM microsoft/aspnetcore:2.0.3 AS base +FROM microsoft/aspnetcore:2.0.5 AS base WORKDIR /app EXPOSE 80 -FROM microsoft/aspnetcore-build:2.0 AS build +FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build WORKDIR /src COPY . . RUN dotnet restore -nowarn:msb3202,nu1503 diff --git a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs index 76a78bad7..546483b40 100644 --- a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs +++ b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs @@ -30,7 +30,8 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Even private async Task UpdatePriceInBasketItems(int productId, decimal newPrice, decimal oldPrice, CustomerBasket basket) { - var itemsToUpdate = basket?.Items?.Where(x => int.Parse(x.ProductId) == productId).ToList(); + string match = productId.ToString(); + var itemsToUpdate = basket?.Items?.Where(x => x.ProductId == match).ToList(); if (itemsToUpdate != null) { diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index 86b57c0cd..7d65ba8b4 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -205,7 +205,8 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API .UseSwaggerUI(c => { c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Basket.API V1"); - c.ConfigureOAuth2("basketswaggerui", "", "", "Basket Swagger UI"); + c.OAuthClientId ("basketswaggerui"); + c.OAuthAppName("Basket Swagger UI"); }); ConfigureEventBus(app); diff --git a/src/Services/Catalog/Catalog.API/Catalog.API.csproj b/src/Services/Catalog/Catalog.API/Catalog.API.csproj index acb17ce16..55e7f8be5 100644 --- a/src/Services/Catalog/Catalog.API/Catalog.API.csproj +++ b/src/Services/Catalog/Catalog.API/Catalog.API.csproj @@ -34,13 +34,13 @@ - - - - + + + + - - + + diff --git a/src/Services/Catalog/Catalog.API/Dockerfile b/src/Services/Catalog/Catalog.API/Dockerfile index a73b51dcf..a1279db8c 100644 --- a/src/Services/Catalog/Catalog.API/Dockerfile +++ b/src/Services/Catalog/Catalog.API/Dockerfile @@ -1,8 +1,8 @@ -FROM microsoft/aspnetcore:2.0.3 AS base +FROM microsoft/aspnetcore:2.0.5 AS base WORKDIR /app EXPOSE 80 -FROM microsoft/aspnetcore-build:2.0 AS build +FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build WORKDIR /src COPY . . RUN dotnet restore -nowarn:msb3202,nu1503 diff --git a/src/Services/Identity/Identity.API/Dockerfile b/src/Services/Identity/Identity.API/Dockerfile index e5b453731..ddc884cc2 100644 --- a/src/Services/Identity/Identity.API/Dockerfile +++ b/src/Services/Identity/Identity.API/Dockerfile @@ -1,8 +1,8 @@ -FROM microsoft/aspnetcore:2.0.3 AS base +FROM microsoft/aspnetcore:2.0.5 AS base WORKDIR /app EXPOSE 80 -FROM microsoft/aspnetcore-build:2.0 AS build +FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build WORKDIR /src COPY . . RUN dotnet restore -nowarn:msb3202,nu1503 diff --git a/src/Services/Identity/Identity.API/Identity.API.csproj b/src/Services/Identity/Identity.API/Identity.API.csproj index 0d30c43c0..5a30673e6 100644 --- a/src/Services/Identity/Identity.API/Identity.API.csproj +++ b/src/Services/Identity/Identity.API/Identity.API.csproj @@ -14,16 +14,16 @@ - - - - + + + + - - - + + + - + diff --git a/src/Services/Location/Locations.API/Dockerfile b/src/Services/Location/Locations.API/Dockerfile index 9f42ab1f9..e2b64ba2e 100644 --- a/src/Services/Location/Locations.API/Dockerfile +++ b/src/Services/Location/Locations.API/Dockerfile @@ -1,8 +1,8 @@ -FROM microsoft/aspnetcore:2.0.3 AS base +FROM microsoft/aspnetcore:2.0.5 AS base WORKDIR /app EXPOSE 80 -FROM microsoft/aspnetcore-build:2.0 AS build +FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build WORKDIR /src COPY . . RUN dotnet restore -nowarn:msb3202,nu1503 diff --git a/src/Services/Location/Locations.API/Locations.API.csproj b/src/Services/Location/Locations.API/Locations.API.csproj index e1c41a251..13cb71821 100644 --- a/src/Services/Location/Locations.API/Locations.API.csproj +++ b/src/Services/Location/Locations.API/Locations.API.csproj @@ -6,18 +6,18 @@ aspnet-Locations.API-20161122013619 - - - - + + + + - + - - + + diff --git a/src/Services/Location/Locations.API/Startup.cs b/src/Services/Location/Locations.API/Startup.cs index e69180e61..be0263312 100644 --- a/src/Services/Location/Locations.API/Startup.cs +++ b/src/Services/Location/Locations.API/Startup.cs @@ -176,7 +176,8 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API .UseSwaggerUI(c => { c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Locations.API V1"); - c.ConfigureOAuth2("locationsswaggerui", "", "", "Locations Swagger UI"); + c.OAuthClientId("locationsswaggerui"); + c.OAuthAppName("Locations Swagger UI"); }); LocationsContextSeed.SeedAsync(app, loggerFactory) diff --git a/src/Services/Marketing/Marketing.API/Dockerfile b/src/Services/Marketing/Marketing.API/Dockerfile index dea524632..b30986406 100644 --- a/src/Services/Marketing/Marketing.API/Dockerfile +++ b/src/Services/Marketing/Marketing.API/Dockerfile @@ -1,8 +1,8 @@ -FROM microsoft/aspnetcore:2.0.3 AS base +FROM microsoft/aspnetcore:2.0.5 AS base WORKDIR /app EXPOSE 80 -FROM microsoft/aspnetcore-build:2.0 AS build +FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build WORKDIR /src COPY . . RUN dotnet restore -nowarn:msb3202,nu1503 diff --git a/src/Services/Marketing/Marketing.API/Marketing.API.csproj b/src/Services/Marketing/Marketing.API/Marketing.API.csproj index a6c6eb83b..3f07c3970 100644 --- a/src/Services/Marketing/Marketing.API/Marketing.API.csproj +++ b/src/Services/Marketing/Marketing.API/Marketing.API.csproj @@ -20,17 +20,17 @@ - - - - + + + + - + - + diff --git a/src/Services/Marketing/Marketing.API/Startup.cs b/src/Services/Marketing/Marketing.API/Startup.cs index f2dcd1578..5683dc72d 100644 --- a/src/Services/Marketing/Marketing.API/Startup.cs +++ b/src/Services/Marketing/Marketing.API/Startup.cs @@ -208,7 +208,8 @@ .UseSwaggerUI(c => { c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Marketing.API V1"); - c.ConfigureOAuth2("marketingswaggerui", "", "", "Marketing Swagger UI"); + c.OAuthClientId("marketingswaggerui"); + c.OAuthAppName("Marketing Swagger UI"); }); ConfigureEventBus(app); diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/IdentifiedCommandHandler.cs b/src/Services/Ordering/Ordering.API/Application/Commands/IdentifiedCommandHandler.cs index 1f0b3ddca..f00ea44c8 100644 --- a/src/Services/Ordering/Ordering.API/Application/Commands/IdentifiedCommandHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/Commands/IdentifiedCommandHandler.cs @@ -48,11 +48,16 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands else { await _requestManager.CreateRequestForCommandAsync(message.Id); - - // Send the embeded business command to mediator so it runs its related CommandHandler - var result = await _mediator.Send(message.Command); - - return result; + try + { + // Send the embeded business command to mediator so it runs its related CommandHandler + var result = await _mediator.Send(message.Command); + return result; + } + catch + { + return default(R); + } } } } diff --git a/src/Services/Ordering/Ordering.API/Dockerfile b/src/Services/Ordering/Ordering.API/Dockerfile index d3076209f..6dc5f8122 100644 --- a/src/Services/Ordering/Ordering.API/Dockerfile +++ b/src/Services/Ordering/Ordering.API/Dockerfile @@ -1,8 +1,8 @@ -FROM microsoft/aspnetcore:2.0.3 AS base +FROM microsoft/aspnetcore:2.0.5 AS base WORKDIR /app EXPOSE 80 -FROM microsoft/aspnetcore-build:2.0 AS build +FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build WORKDIR /src COPY . . RUN dotnet restore -nowarn:msb3202,nu1503 diff --git a/src/Services/Ordering/Ordering.API/Ordering.API.csproj b/src/Services/Ordering/Ordering.API/Ordering.API.csproj index 533149591..c1ee1f57c 100644 --- a/src/Services/Ordering/Ordering.API/Ordering.API.csproj +++ b/src/Services/Ordering/Ordering.API/Ordering.API.csproj @@ -30,20 +30,20 @@ - + - - - - + + + + - + - + - + diff --git a/src/Services/Ordering/Ordering.API/Startup.cs b/src/Services/Ordering/Ordering.API/Startup.cs index 1879175c9..bf715c235 100644 --- a/src/Services/Ordering/Ordering.API/Startup.cs +++ b/src/Services/Ordering/Ordering.API/Startup.cs @@ -226,7 +226,8 @@ .UseSwaggerUI(c => { c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Ordering.API V1"); - c.ConfigureOAuth2("orderingswaggerui", "", "", "Ordering Swagger UI"); + c.OAuthClientId("orderingswaggerui"); + c.OAuthAppName("Ordering Swagger UI"); }); ConfigureEventBus(app); diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile b/src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile index 391d8c17b..a675d59ef 100644 --- a/src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile +++ b/src/Services/Ordering/Ordering.BackgroundTasks/Dockerfile @@ -1,8 +1,8 @@ -FROM microsoft/aspnetcore:2.0.3 AS base +FROM microsoft/aspnetcore:2.0.5 AS base WORKDIR /app EXPOSE 80 -FROM microsoft/aspnetcore-build:2.0 AS build +FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build WORKDIR /src COPY . . RUN dotnet restore -nowarn:msb3202,nu1503 diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj b/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj index 731d6df06..f2a7ad465 100644 --- a/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj +++ b/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj @@ -11,9 +11,9 @@ - + - + diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Address.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Address.cs index 9576940df..b05ea92bf 100644 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Address.cs +++ b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Address.cs @@ -6,11 +6,11 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O { public class Address : ValueObject { - public String Street { get; private set; } - public String City { get; private set; } - public String State { get; private set; } - public String Country { get; private set; } - public String ZipCode { get; private set; } + public String Street { get; } + public String City { get; } + public String State { get; } + public String Country { get; } + public String ZipCode { get; } private Address() { } diff --git a/src/Services/Ordering/Ordering.Domain/Events/OrderStartedDomainEvent.cs b/src/Services/Ordering/Ordering.Domain/Events/OrderStartedDomainEvent.cs index a457067f6..1b47ae901 100644 --- a/src/Services/Ordering/Ordering.Domain/Events/OrderStartedDomainEvent.cs +++ b/src/Services/Ordering/Ordering.Domain/Events/OrderStartedDomainEvent.cs @@ -11,13 +11,13 @@ namespace Ordering.Domain.Events /// public class OrderStartedDomainEvent : INotification { - public string UserId { get; private set; } - public int CardTypeId { get; private set; } - public string CardNumber { get; private set; } - public string CardSecurityNumber { get; private set; } - public string CardHolderName { get; private set; } - public DateTime CardExpiration { get; private set; } - public Order Order { get; private set; } + public string UserId { get; } + public int CardTypeId { get; } + public string CardNumber { get; } + public string CardSecurityNumber { get; } + public string CardHolderName { get; } + public DateTime CardExpiration { get; } + public Order Order { get; } public OrderStartedDomainEvent(Order order, string userId, int cardTypeId, string cardNumber, diff --git a/src/Services/Ordering/Ordering.Domain/SeedWork/Entity.cs b/src/Services/Ordering/Ordering.Domain/SeedWork/Entity.cs index 11b940218..a1f2fa1c8 100644 --- a/src/Services/Ordering/Ordering.Domain/SeedWork/Entity.cs +++ b/src/Services/Ordering/Ordering.Domain/SeedWork/Entity.cs @@ -21,17 +21,22 @@ } private List _domainEvents; - public List DomainEvents => _domainEvents; - + public IReadOnlyCollection DomainEvents => _domainEvents?.AsReadOnly(); + public void AddDomainEvent(INotification eventItem) { _domainEvents = _domainEvents ?? new List(); _domainEvents.Add(eventItem); } + public void RemoveDomainEvent(INotification eventItem) { - if (_domainEvents is null) return; - _domainEvents.Remove(eventItem); + _domainEvents?.Remove(eventItem); + } + + public void ClearDomainEvents() + { + _domainEvents?.Clear(); } public bool IsTransient() diff --git a/src/Services/Ordering/Ordering.Domain/SeedWork/Enumeration.cs b/src/Services/Ordering/Ordering.Domain/SeedWork/Enumeration.cs index ecf248be9..ff261a61c 100644 --- a/src/Services/Ordering/Ordering.Domain/SeedWork/Enumeration.cs +++ b/src/Services/Ordering/Ordering.Domain/SeedWork/Enumeration.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -11,9 +11,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork public int Id { get; private set; } - protected Enumeration() - { - } + protected Enumeration(){} protected Enumeration(int id, string name) { @@ -21,10 +19,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork Name = name; } - public override string ToString() - { - return Name; - } + public override string ToString() => Name; public static IEnumerable GetAll() where T : Enumeration, new() { @@ -37,9 +32,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork var locatedValue = info.GetValue(instance) as T; if (locatedValue != null) - { yield return locatedValue; - } } } @@ -48,9 +41,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork var otherValue = obj as Enumeration; if (otherValue == null) - { return false; - } var typeMatches = GetType().Equals(obj.GetType()); var valueMatches = Id.Equals(otherValue.Id); @@ -58,10 +49,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork return typeMatches && valueMatches; } - public override int GetHashCode() - { - return Id.GetHashCode(); - } + public override int GetHashCode() => Id.GetHashCode(); public static int AbsoluteDifference(Enumeration firstValue, Enumeration secondValue) { @@ -86,18 +74,11 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork var matchingItem = GetAll().FirstOrDefault(predicate); if (matchingItem == null) - { - var message = string.Format("'{0}' is not a valid {1} in {2}", value, description, typeof(T)); - - throw new InvalidOperationException(message); - } + throw new InvalidOperationException($"'{value}' is not a valid {description} in {typeof(T)}"); return matchingItem; } - public int CompareTo(object other) - { - return Id.CompareTo(((Enumeration)other).Id); - } + public int CompareTo(object other) => Id.CompareTo(((Enumeration) other).Id); } } diff --git a/src/Services/Ordering/Ordering.Infrastructure/MediatorExtension.cs b/src/Services/Ordering/Ordering.Infrastructure/MediatorExtension.cs index 521f85ae8..82a7235a2 100644 --- a/src/Services/Ordering/Ordering.Infrastructure/MediatorExtension.cs +++ b/src/Services/Ordering/Ordering.Infrastructure/MediatorExtension.cs @@ -19,7 +19,7 @@ namespace Ordering.Infrastructure .ToList(); domainEntities.ToList() - .ForEach(entity => entity.Entity.DomainEvents.Clear()); + .ForEach(entity => entity.Entity.ClearDomainEvents()); var tasks = domainEvents .Select(async (domainEvent) => { diff --git a/src/Services/Payment/Payment.API/Dockerfile b/src/Services/Payment/Payment.API/Dockerfile index 896a81f84..7b19579c1 100644 --- a/src/Services/Payment/Payment.API/Dockerfile +++ b/src/Services/Payment/Payment.API/Dockerfile @@ -1,8 +1,8 @@ -FROM microsoft/aspnetcore:2.0.3 AS base +FROM microsoft/aspnetcore:2.0.5 AS base WORKDIR /app EXPOSE 80 -FROM microsoft/aspnetcore-build:2.0 AS build +FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build WORKDIR /src COPY . . RUN dotnet restore -nowarn:msb3202,nu1503 diff --git a/src/Services/Payment/Payment.API/Payment.API.csproj b/src/Services/Payment/Payment.API/Payment.API.csproj index bd0d595c0..e7e4fc739 100644 --- a/src/Services/Payment/Payment.API/Payment.API.csproj +++ b/src/Services/Payment/Payment.API/Payment.API.csproj @@ -7,12 +7,12 @@ - - - - + + + + - + diff --git a/src/Web/WebMVC/Dockerfile b/src/Web/WebMVC/Dockerfile index 5fb657dd8..a903387c8 100644 --- a/src/Web/WebMVC/Dockerfile +++ b/src/Web/WebMVC/Dockerfile @@ -1,8 +1,8 @@ -FROM microsoft/aspnetcore:2.0.3 AS base +FROM microsoft/aspnetcore:2.0.5 AS base WORKDIR /app EXPOSE 80 -FROM microsoft/aspnetcore-build:2.0 AS build +FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build WORKDIR /src COPY . . RUN dotnet restore -nowarn:msb3202,nu1503 diff --git a/src/Web/WebMVC/WebMVC.csproj b/src/Web/WebMVC/WebMVC.csproj index d31fec311..ac2261a45 100644 --- a/src/Web/WebMVC/WebMVC.csproj +++ b/src/Web/WebMVC/WebMVC.csproj @@ -18,13 +18,13 @@ - - - + + + - + - + diff --git a/src/Web/WebSPA/Dockerfile b/src/Web/WebSPA/Dockerfile index 47032f41f..7b7cd47d4 100644 --- a/src/Web/WebSPA/Dockerfile +++ b/src/Web/WebSPA/Dockerfile @@ -1,8 +1,8 @@ -FROM microsoft/aspnetcore:2.0.3 AS base +FROM microsoft/aspnetcore:2.0.5 AS base WORKDIR /app EXPOSE 80 -FROM microsoft/aspnetcore-build:2.0 AS build +FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build WORKDIR /src COPY . . RUN dotnet restore -nowarn:msb3202,nu1503 diff --git a/src/Web/WebSPA/WebSPA.csproj b/src/Web/WebSPA/WebSPA.csproj index 00199f08f..7d82fda2b 100644 --- a/src/Web/WebSPA/WebSPA.csproj +++ b/src/Web/WebSPA/WebSPA.csproj @@ -27,13 +27,13 @@ - - - + + + - + - + diff --git a/src/Web/WebStatus/Dockerfile b/src/Web/WebStatus/Dockerfile index b143bd875..16d4cbc61 100644 --- a/src/Web/WebStatus/Dockerfile +++ b/src/Web/WebStatus/Dockerfile @@ -1,8 +1,8 @@ -FROM microsoft/aspnetcore:2.0.3 AS base +FROM microsoft/aspnetcore:2.0.5 AS base WORKDIR /app EXPOSE 80 -FROM microsoft/aspnetcore-build:2.0 AS build +FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build WORKDIR /src COPY . . RUN dotnet restore -nowarn:msb3202,nu1503 @@ -16,3 +16,4 @@ FROM base AS final WORKDIR /app COPY --from=publish /app . ENTRYPOINT ["dotnet", "WebStatus.dll"] + diff --git a/src/Web/WebStatus/WebStatus.csproj b/src/Web/WebStatus/WebStatus.csproj index 02ee3e622..32a311f9d 100644 --- a/src/Web/WebStatus/WebStatus.csproj +++ b/src/Web/WebStatus/WebStatus.csproj @@ -5,11 +5,11 @@ ..\..\..\docker-compose.dcproj - - - + + + - + diff --git a/test/Services/FunctionalTests/FunctionalTests.csproj b/test/Services/FunctionalTests/FunctionalTests.csproj index c85cd2e67..96ed1510f 100644 --- a/test/Services/FunctionalTests/FunctionalTests.csproj +++ b/test/Services/FunctionalTests/FunctionalTests.csproj @@ -44,10 +44,10 @@ - - - - + + + + diff --git a/test/Services/IntegrationTests/IntegrationTests.csproj b/test/Services/IntegrationTests/IntegrationTests.csproj index e3fe11e13..bf176495a 100644 --- a/test/Services/IntegrationTests/IntegrationTests.csproj +++ b/test/Services/IntegrationTests/IntegrationTests.csproj @@ -2,8 +2,8 @@ netcoreapp2.0 - FunctionalTests - FunctionalTests + IntegrationTests + IntegrationTests true $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; false @@ -44,13 +44,13 @@ - - - - + + + + - - + + diff --git a/test/Services/IntegrationTests/Services/Basket/BasketScenarios.cs b/test/Services/IntegrationTests/Services/Basket/BasketScenarios.cs index 451b1fbf7..747efc8ed 100644 --- a/test/Services/IntegrationTests/Services/Basket/BasketScenarios.cs +++ b/test/Services/IntegrationTests/Services/Basket/BasketScenarios.cs @@ -58,6 +58,15 @@ namespace IntegrationTests.Services.Basket string BuildBasket() { var order = new CustomerBasket("1234"); + + order.Items.Add(new BasketItem + { + ProductId = "1", + ProductName = ".NET Bot Black Hoodie", + UnitPrice = 10, + Quantity = 1 + }); + return JsonConvert.SerializeObject(order); } @@ -70,10 +79,10 @@ namespace IntegrationTests.Services.Basket State = "state", Country = "coutry", ZipCode = "zipcode", - CardNumber = "CardNumber", + CardNumber = "1234567890123456", CardHolderName = "CardHolderName", - CardExpiration = DateTime.UtcNow, - CardSecurityNumber = "1234", + CardExpiration = DateTime.UtcNow.AddDays(1), + CardSecurityNumber = "123", CardTypeId = 1, Buyer = "Buyer", RequestId = Guid.NewGuid() diff --git a/test/Services/UnitTest/UnitTest.csproj b/test/Services/UnitTest/UnitTest.csproj index 7c008e431..ebc17095f 100644 --- a/test/Services/UnitTest/UnitTest.csproj +++ b/test/Services/UnitTest/UnitTest.csproj @@ -21,12 +21,12 @@ - - + + - - - + + +