From 34241c430619b3b0bbeaabafa44c078c859237c4 Mon Sep 17 00:00:00 2001 From: Viswanatha Swamy Date: Wed, 2 Dec 2020 01:30:31 +0530 Subject: [PATCH] Removed unused using, Reorganized using, moved the class to separate file, removed commented code in Catalog.API --- .../Base/BasketTestStartup.cs | 4 +- .../Catalog/Catalog.API/CatalogSettings.cs | 7 ++- .../Extensions/CatalogItemExtensions.cs | 7 +-- .../Catalog.API/Extensions/HostExtensions.cs | 7 +-- .../Extensions/WebHostExtensions.cs | 6 +-- .../Catalog.API/Grpc/CatalogService.cs | 11 ++-- .../Infrastructure/CatalogContext.cs | 4 +- .../CatalogIntegrationEventService.cs | 2 - ...aitingValidationIntegrationEventHandler.cs | 10 ++-- ...tusChangedToPaidIntegrationEventHandler.cs | 2 +- ...gedToAwaitingValidationIntegrationEvent.cs | 11 ---- .../Events/OrderStockItem.cs | 14 +++++ src/Services/Catalog/Catalog.API/Program.cs | 5 +- .../Catalog/Catalog.API/Proto/catalog.proto | 53 +++++++++++-------- src/Services/Catalog/Catalog.API/Startup.cs | 1 - 15 files changed, 72 insertions(+), 72 deletions(-) create mode 100644 src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockItem.cs diff --git a/src/Services/Basket/Basket.FunctionalTests/Base/BasketTestStartup.cs b/src/Services/Basket/Basket.FunctionalTests/Base/BasketTestStartup.cs index cb8ec86418..d2f2c97352 100644 --- a/src/Services/Basket/Basket.FunctionalTests/Base/BasketTestStartup.cs +++ b/src/Services/Basket/Basket.FunctionalTests/Base/BasketTestStartup.cs @@ -1,9 +1,9 @@ -using System; -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Routing; using Microsoft.eShopOnContainers.Services.Basket.API; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using System; namespace Basket.FunctionalTests.Base { diff --git a/src/Services/Catalog/Catalog.API/CatalogSettings.cs b/src/Services/Catalog/Catalog.API/CatalogSettings.cs index a8c47991e6..2e1d22e8bd 100644 --- a/src/Services/Catalog/Catalog.API/CatalogSettings.cs +++ b/src/Services/Catalog/Catalog.API/CatalogSettings.cs @@ -1,12 +1,15 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API { + public class CatalogSettings { - public string PicBaseUrl { get;set;} + public string PicBaseUrl { get; set; } public string EventBusConnection { get; set; } public bool UseCustomizationData { get; set; } - public bool AzureStorageEnabled { get; set; } + + public bool AzureStorageEnabled { get; set; } } + } diff --git a/src/Services/Catalog/Catalog.API/Extensions/CatalogItemExtensions.cs b/src/Services/Catalog/Catalog.API/Extensions/CatalogItemExtensions.cs index fa2c3f60ec..e953df581b 100644 --- a/src/Services/Catalog/Catalog.API/Extensions/CatalogItemExtensions.cs +++ b/src/Services/Catalog/Catalog.API/Extensions/CatalogItemExtensions.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Services.Catalog.API.Model +namespace Microsoft.eShopOnContainers.Services.Catalog.API.Model { public static class CatalogItemExtensions { diff --git a/src/Services/Catalog/Catalog.API/Extensions/HostExtensions.cs b/src/Services/Catalog/Catalog.API/Extensions/HostExtensions.cs index cfa7e9d2f2..ccdd73558a 100644 --- a/src/Services/Catalog/Catalog.API/Extensions/HostExtensions.cs +++ b/src/Services/Catalog/Catalog.API/Extensions/HostExtensions.cs @@ -1,13 +1,10 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Hosting; -using System; using Microsoft.Extensions.DependencyInjection; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Polly; +using System; using System.Data.SqlClient; namespace Catalog.API.Extensions diff --git a/src/Services/Catalog/Catalog.API/Extensions/WebHostExtensions.cs b/src/Services/Catalog/Catalog.API/Extensions/WebHostExtensions.cs index b7a982b2e5..07fc117705 100644 --- a/src/Services/Catalog/Catalog.API/Extensions/WebHostExtensions.cs +++ b/src/Services/Catalog/Catalog.API/Extensions/WebHostExtensions.cs @@ -1,11 +1,11 @@ -using Microsoft.EntityFrameworkCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; -using System; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Polly; +using System; using System.Data.SqlClient; -using Microsoft.AspNetCore.Hosting; namespace Catalog.API.Extensions { diff --git a/src/Services/Catalog/Catalog.API/Grpc/CatalogService.cs b/src/Services/Catalog/Catalog.API/Grpc/CatalogService.cs index ef22b5be25..e502780ee5 100644 --- a/src/Services/Catalog/Catalog.API/Grpc/CatalogService.cs +++ b/src/Services/Catalog/Catalog.API/Grpc/CatalogService.cs @@ -1,16 +1,15 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using CatalogApi; +using CatalogApi; using Grpc.Core; using Microsoft.EntityFrameworkCore; using Microsoft.eShopOnContainers.Services.Catalog.API; using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; using Microsoft.eShopOnContainers.Services.Catalog.API.Model; -using Microsoft.eShopOnContainers.Services.Catalog.API.ViewModel; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; using static CatalogApi.Catalog; namespace Catalog.API.Grpc diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs index 8cff66b08e..cee4b5e334 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs @@ -1,9 +1,9 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure { - using Microsoft.EntityFrameworkCore; using EntityConfigurations; - using Model; + using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; + using Model; public class CatalogContext : DbContext { diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs index 3e7ba9868c..6c48392977 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs @@ -1,5 +1,4 @@ using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Storage; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events; using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services; @@ -7,7 +6,6 @@ using Microsoft.eShopOnContainers.Services.Catalog.API; using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; using Microsoft.Extensions.Logging; -using Serilog.Context; using System; using System.Data.Common; using System.Threading.Tasks; diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs index 493a271ccd..d7da9951e7 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs @@ -1,15 +1,15 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling { using BuildingBlocks.EventBus.Abstractions; - using System.Threading.Tasks; using BuildingBlocks.EventBus.Events; - using Infrastructure; - using System.Collections.Generic; - using System.Linq; using global::Catalog.API.IntegrationEvents; + using Infrastructure; using IntegrationEvents.Events; - using Serilog.Context; using Microsoft.Extensions.Logging; + using Serilog.Context; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; public class OrderStatusChangedToAwaitingValidationIntegrationEventHandler : IIntegrationEventHandler diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs index 7d383254fb..1a8836186e 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs @@ -1,11 +1,11 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling { using BuildingBlocks.EventBus.Abstractions; - using System.Threading.Tasks; using Infrastructure; using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events; using Microsoft.Extensions.Logging; using Serilog.Context; + using System.Threading.Tasks; public class OrderStatusChangedToPaidIntegrationEventHandler : IIntegrationEventHandler diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs index 9787aaedd3..bcfe3f64d2 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStatusChangedToAwaitingValidationIntegrationEvent.cs @@ -16,15 +16,4 @@ public OrderStatusChangedToAwaitingValidationIntegrationEvent(int orderId, } } - public class OrderStockItem - { - public int ProductId { get; } - public int Units { get; } - - public OrderStockItem(int productId, int units) - { - ProductId = productId; - Units = units; - } - } } \ No newline at end of file diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockItem.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockItem.cs new file mode 100644 index 0000000000..2006140d3b --- /dev/null +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/OrderStockItem.cs @@ -0,0 +1,14 @@ +namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events +{ + public class OrderStockItem + { + public int ProductId { get; } + public int Units { get; } + + public OrderStockItem(int productId, int units) + { + ProductId = productId; + Units = units; + } + } +} \ No newline at end of file diff --git a/src/Services/Catalog/Catalog.API/Program.cs b/src/Services/Catalog/Catalog.API/Program.cs index 3632609b4e..b737d0142e 100644 --- a/src/Services/Catalog/Catalog.API/Program.cs +++ b/src/Services/Catalog/Catalog.API/Program.cs @@ -1,5 +1,4 @@ -using Autofac.Extensions.DependencyInjection; -using Catalog.API.Extensions; +using Catalog.API.Extensions; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Server.Kestrel.Core; @@ -12,9 +11,7 @@ using Microsoft.Extensions.Options; using Serilog; using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net; namespace Microsoft.eShopOnContainers.Services.Catalog.API diff --git a/src/Services/Catalog/Catalog.API/Proto/catalog.proto b/src/Services/Catalog/Catalog.API/Proto/catalog.proto index fa83d45c40..15de3e1033 100644 --- a/src/Services/Catalog/Catalog.API/Proto/catalog.proto +++ b/src/Services/Catalog/Catalog.API/Proto/catalog.proto @@ -1,60 +1,69 @@ syntax = "proto3"; -/* >> -import "google/api/annotations.proto"; -<< */ - - package CatalogApi; message CatalogItemRequest { int32 id = 1; } + message CatalogItemsRequest { string ids = 1; + int32 pageSize = 2; + int32 pageIndex = 3; } message CatalogItemResponse { int32 id = 1; + string name = 2; - string description=3; - double price=4; - string picture_file_name=5; - string picture_uri=6; - CatalogType catalog_type=8; - CatalogBrand catalog_brand=10; - int32 available_stock=11; - int32 restock_threshold=12; - int32 max_stock_threshold=13; - bool on_reorder=14; + + string description=3; + + double price=4; + + string picture_file_name=5; + + string picture_uri=6; + + CatalogType catalog_type=8; + + CatalogBrand catalog_brand=10; + + int32 available_stock=11; + + int32 restock_threshold=12; + + int32 max_stock_threshold=13; + + bool on_reorder=14; } message CatalogBrand { int32 id = 1; + string name = 2; } message CatalogType { int32 id = 1; + string type = 2; } message PaginatedItemsResponse { int32 pageIndex = 1; + int32 pageSize = 2; + int64 count = 3; + repeated CatalogItemResponse data = 4; } service Catalog { - rpc GetItemById (CatalogItemRequest) returns (CatalogItemResponse) { - /* >> - option (google.api.http) = { - get: "/api/v1/catalog/items/{id}" - }; - << */ - } + rpc GetItemById (CatalogItemRequest) returns (CatalogItemResponse) {} + rpc GetItemsByIds (CatalogItemsRequest) returns (PaginatedItemsResponse) {} } \ No newline at end of file diff --git a/src/Services/Catalog/Catalog.API/Startup.cs b/src/Services/Catalog/Catalog.API/Startup.cs index 836b6a7b81..2b7082e25b 100644 --- a/src/Services/Catalog/Catalog.API/Startup.cs +++ b/src/Services/Catalog/Catalog.API/Startup.cs @@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.ServiceBus; using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;