diff --git a/src/Services/Catalog/Catalog.API/CatalogSettings.cs b/src/Services/Catalog/Catalog.API/CatalogSettings.cs index 3bff82f3f..297c68914 100644 --- a/src/Services/Catalog/Catalog.API/CatalogSettings.cs +++ b/src/Services/Catalog/Catalog.API/CatalogSettings.cs @@ -2,7 +2,7 @@ { public class CatalogSettings { - public string PicBaseUrl { get;set;} + public string PicBaseUrl { get; set; } public string EventBusConnection { get; set; } diff --git a/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs b/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs index 5dfb10a96..d58c06f66 100644 --- a/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs +++ b/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs @@ -37,7 +37,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers [ProducesResponseType(typeof(PaginatedItemsViewModel), (int)HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable), (int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.BadRequest)] - public async Task ItemsAsync([FromQuery]int pageSize = 10, [FromQuery]int pageIndex = 0, string ids = null) + public async Task ItemsAsync([FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0, string ids = null) { if (!string.IsNullOrEmpty(ids)) { @@ -126,7 +126,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers [HttpGet] [Route("items/withname/{name:minlength(1)}")] [ProducesResponseType(typeof(PaginatedItemsViewModel), (int)HttpStatusCode.OK)] - public async Task>> ItemsWithNameAsync(string name, [FromQuery]int pageSize = 10, [FromQuery]int pageIndex = 0) + public async Task>> ItemsWithNameAsync(string name, [FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0) { var totalItems = await _catalogContext.CatalogItems .Where(c => c.Name.StartsWith(name)) @@ -147,7 +147,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers [HttpGet] [Route("items/type/{catalogTypeId}/brand/{catalogBrandId:int?}")] [ProducesResponseType(typeof(PaginatedItemsViewModel), (int)HttpStatusCode.OK)] - public async Task>> ItemsByTypeIdAndBrandIdAsync(int catalogTypeId, int? catalogBrandId, [FromQuery]int pageSize = 10, [FromQuery]int pageIndex = 0) + public async Task>> ItemsByTypeIdAndBrandIdAsync(int catalogTypeId, int? catalogBrandId, [FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0) { var root = (IQueryable)_catalogContext.CatalogItems; @@ -175,7 +175,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers [HttpGet] [Route("items/type/all/brand/{catalogBrandId:int?}")] [ProducesResponseType(typeof(PaginatedItemsViewModel), (int)HttpStatusCode.OK)] - public async Task>> ItemsByBrandIdAsync(int? catalogBrandId, [FromQuery]int pageSize = 10, [FromQuery]int pageIndex = 0) + public async Task>> ItemsByBrandIdAsync(int? catalogBrandId, [FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0) { var root = (IQueryable)_catalogContext.CatalogItems; @@ -220,7 +220,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers [HttpPut] [ProducesResponseType((int)HttpStatusCode.NotFound)] [ProducesResponseType((int)HttpStatusCode.Created)] - public async Task UpdateProductAsync([FromBody]CatalogItem productToUpdate) + public async Task UpdateProductAsync([FromBody] CatalogItem productToUpdate) { var catalogItem = await _catalogContext.CatalogItems.SingleOrDefaultAsync(i => i.Id == productToUpdate.Id); @@ -259,7 +259,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers [Route("items")] [HttpPost] [ProducesResponseType((int)HttpStatusCode.Created)] - public async Task CreateProductAsync([FromBody]CatalogItem product) + public async Task CreateProductAsync([FromBody] CatalogItem product) { var item = new CatalogItem { diff --git a/src/Services/Catalog/Catalog.API/Grpc/CatalogService.cs b/src/Services/Catalog/Catalog.API/Grpc/CatalogService.cs index e502780ee..4fabfbeb4 100644 --- a/src/Services/Catalog/Catalog.API/Grpc/CatalogService.cs +++ b/src/Services/Catalog/Catalog.API/Grpc/CatalogService.cs @@ -19,6 +19,7 @@ namespace Catalog.API.Grpc private readonly CatalogContext _catalogContext; private readonly CatalogSettings _settings; private readonly ILogger _logger; + public CatalogService(CatalogContext dbContext, IOptions settings, ILogger logger) { _settings = settings.Value; diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs index cee4b5e33..ee440c1ef 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs @@ -19,7 +19,7 @@ builder.ApplyConfiguration(new CatalogBrandEntityTypeConfiguration()); builder.ApplyConfiguration(new CatalogTypeEntityTypeConfiguration()); builder.ApplyConfiguration(new CatalogItemEntityTypeConfiguration()); - } + } } @@ -27,7 +27,7 @@ { public CatalogContext CreateDbContext(string[] args) { - var optionsBuilder = new DbContextOptionsBuilder() + var optionsBuilder = new DbContextOptionsBuilder() .UseSqlServer("Server=.;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;Integrated Security=true"); return new CatalogContext(optionsBuilder.Options); diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs index e425072e0..5416b377a 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs @@ -19,7 +19,7 @@ public class CatalogContextSeed { - public async Task SeedAsync(CatalogContext context,IWebHostEnvironment env,IOptions settings,ILogger logger) + public async Task SeedAsync(CatalogContext context, IWebHostEnvironment env, IOptions settings, ILogger logger) { var policy = CreatePolicy(logger, nameof(CatalogContextSeed)); @@ -73,7 +73,7 @@ try { string[] requiredHeaders = { "catalogbrand" }; - csvheaders = GetHeaders( csvFileCatalogBrands, requiredHeaders ); + csvheaders = GetHeaders(csvFileCatalogBrands, requiredHeaders); } catch (Exception ex) { @@ -128,7 +128,7 @@ try { string[] requiredHeaders = { "catalogtype" }; - csvheaders = GetHeaders( csvFileCatalogTypes, requiredHeaders ); + csvheaders = GetHeaders(csvFileCatalogTypes, requiredHeaders); } catch (Exception ex) { @@ -183,7 +183,7 @@ { string[] requiredHeaders = { "catalogtypename", "catalogbrandname", "description", "name", "price", "picturefilename" }; string[] optionalheaders = { "availablestock", "restockthreshold", "maxstockthreshold", "onreorder" }; - csvheaders = GetHeaders(csvFileCatalogItems, requiredHeaders, optionalheaders ); + csvheaders = GetHeaders(csvFileCatalogItems, requiredHeaders, optionalheaders); } catch (Exception ex) { @@ -196,7 +196,7 @@ return File.ReadAllLines(csvFileCatalogItems) .Skip(1) // skip header row - .Select(row => Regex.Split(row, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)") ) + .Select(row => Regex.Split(row, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)")) .SelectTry(column => CreateCatalogItem(column, csvheaders, catalogTypeIdLookup, catalogBrandIdLookup)) .OnCaughtException(ex => { logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; }) .Where(x => x != null); @@ -243,7 +243,7 @@ string availableStockString = column[availableStockIndex].Trim('"').Trim(); if (!String.IsNullOrEmpty(availableStockString)) { - if ( int.TryParse(availableStockString, out int availableStock)) + if (int.TryParse(availableStockString, out int availableStock)) { catalogItem.AvailableStock = availableStock; } @@ -370,7 +370,7 @@ } } - private AsyncRetryPolicy CreatePolicy( ILogger logger, string prefix,int retries = 3) + private AsyncRetryPolicy CreatePolicy(ILogger logger, string prefix, int retries = 3) { return Policy.Handle(). WaitAndRetryAsync( diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs index 6c4839297..a691c06b6 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/CatalogIntegrationEventService.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; namespace Catalog.API.IntegrationEvents { - public class CatalogIntegrationEventService : ICatalogIntegrationEventService,IDisposable + public class CatalogIntegrationEventService : ICatalogIntegrationEventService, IDisposable { private readonly Func _integrationEventLogServiceFactory; private readonly IEventBus _eventBus; @@ -73,7 +73,7 @@ namespace Catalog.API.IntegrationEvents { (_eventLogService as IDisposable)?.Dispose(); } - + disposedValue = true; } } diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs index d7da9951e..95da93f75 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs @@ -11,7 +11,7 @@ using System.Linq; using System.Threading.Tasks; - public class OrderStatusChangedToAwaitingValidationIntegrationEventHandler : + public class OrderStatusChangedToAwaitingValidationIntegrationEventHandler : IIntegrationEventHandler { private readonly CatalogContext _catalogContext; diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs index 1a8836186..5a9b4a0f8 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs @@ -7,7 +7,7 @@ using Serilog.Context; using System.Threading.Tasks; - public class OrderStatusChangedToPaidIntegrationEventHandler : + public class OrderStatusChangedToPaidIntegrationEventHandler : IIntegrationEventHandler { private readonly CatalogContext _catalogContext; diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs index 00f25b9e5..eda667a6e 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/Events/ProductPriceChangedIntegrationEvent.cs @@ -6,7 +6,7 @@ // An Event is “something that has happened in the past”, therefore its name has to be past tense // An Integration Event is an event that can cause side effects to other microservices, Bounded-Contexts or external systems. public class ProductPriceChangedIntegrationEvent : IntegrationEvent - { + { public int ProductId { get; private set; } public decimal NewPrice { get; private set; } diff --git a/src/Services/Catalog/Catalog.API/Startup.cs b/src/Services/Catalog/Catalog.API/Startup.cs index 2b7082e25..5747f83b4 100644 --- a/src/Services/Catalog/Catalog.API/Startup.cs +++ b/src/Services/Catalog/Catalog.API/Startup.cs @@ -81,7 +81,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API { c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Catalog.API V1"); }); - + app.UseRouting(); app.UseCors("CorsPolicy"); app.UseEndpoints(endpoints => diff --git a/src/Services/Catalog/Catalog.API/ViewModel/PaginatedItemsViewModel.cs b/src/Services/Catalog/Catalog.API/ViewModel/PaginatedItemsViewModel.cs index 844f38e2b..d088d5bb7 100644 --- a/src/Services/Catalog/Catalog.API/ViewModel/PaginatedItemsViewModel.cs +++ b/src/Services/Catalog/Catalog.API/ViewModel/PaginatedItemsViewModel.cs @@ -15,10 +15,10 @@ public PaginatedItemsViewModel(int pageIndex, int pageSize, long count, IEnumerable data) { - this.PageIndex = pageIndex; - this.PageSize = pageSize; - this.Count = count; - this.Data = data; + PageIndex = pageIndex; + PageSize = pageSize; + Count = count; + Data = data; } } }