From 4ac25bf58d0e11a88df32722ece9df91d3c9a4ff Mon Sep 17 00:00:00 2001 From: KurnakovMaksim <59327306+KurnakovMaksim@users.noreply.github.com> Date: Wed, 9 Mar 2022 17:51:19 +0300 Subject: [PATCH] Little fix and refactoring (#1860) * Delete repeat setting a property in CreateOrderCommand ctor * Fix catalogTypeName -> catalogBrandName in exception message * Delete useless null check from ConsentController * Add null check for subjectId --- .../Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs | 2 +- .../Identity/Identity.API/Controllers/ConsentController.cs | 2 +- src/Services/Identity/Identity.API/Services/ProfileService.cs | 4 ++-- .../Ordering.API/Application/Commands/CreateOrderCommand.cs | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs index ba7589293..0028813e0 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs @@ -203,7 +203,7 @@ public class CatalogContextSeed string catalogBrandName = column[Array.IndexOf(headers, "catalogbrandname")].Trim('"').Trim(); if (!catalogBrandIdLookup.ContainsKey(catalogBrandName)) { - throw new Exception($"type={catalogTypeName} does not exist in catalogTypes"); + throw new Exception($"type={catalogBrandName} does not exist in catalogTypes"); } string priceString = column[Array.IndexOf(headers, "price")].Trim('"').Trim(); diff --git a/src/Services/Identity/Identity.API/Controllers/ConsentController.cs b/src/Services/Identity/Identity.API/Controllers/ConsentController.cs index 6ce04db57..76c27cd23 100644 --- a/src/Services/Identity/Identity.API/Controllers/ConsentController.cs +++ b/src/Services/Identity/Identity.API/Controllers/ConsentController.cs @@ -58,7 +58,7 @@ response = ConsentResponse.Denied; } // user clicked 'yes' - validate the data - else if (model.Button == "yes" && model != null) + else if (model.Button == "yes") { // if the user consented to some scope, build the response model if (model.ScopesConsented != null && model.ScopesConsented.Any()) diff --git a/src/Services/Identity/Identity.API/Services/ProfileService.cs b/src/Services/Identity/Identity.API/Services/ProfileService.cs index 0f0352ad1..6019b4bd8 100644 --- a/src/Services/Identity/Identity.API/Services/ProfileService.cs +++ b/src/Services/Identity/Identity.API/Services/ProfileService.cs @@ -13,7 +13,7 @@ { var subject = context.Subject ?? throw new ArgumentNullException(nameof(context.Subject)); - var subjectId = subject.Claims.Where(x => x.Type == "sub").FirstOrDefault().Value; + var subjectId = subject.Claims.Where(x => x.Type == "sub").FirstOrDefault()?.Value; var user = await _userManager.FindByIdAsync(subjectId); if (user == null) @@ -27,7 +27,7 @@ { var subject = context.Subject ?? throw new ArgumentNullException(nameof(context.Subject)); - var subjectId = subject.Claims.Where(x => x.Type == "sub").FirstOrDefault().Value; + var subjectId = subject.Claims.Where(x => x.Type == "sub").FirstOrDefault()?.Value; var user = await _userManager.FindByIdAsync(subjectId); context.IsActive = false; diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommand.cs b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommand.cs index 071f0657c..fb16306ee 100644 --- a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommand.cs +++ b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommand.cs @@ -79,7 +79,6 @@ public class CreateOrderCommand CardExpiration = cardExpiration; CardSecurityNumber = cardSecurityNumber; CardTypeId = cardTypeId; - CardExpiration = cardExpiration; }