Refactored namespace statements in catalog.api project

This commit is contained in:
Sumit Ghosh 2021-10-11 18:44:14 +05:30
parent a598bfde6c
commit 986262a833
32 changed files with 1782 additions and 1819 deletions

View File

@ -1,5 +1,5 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API;
public class CatalogSettings
{
public string PicBaseUrl { get; set; }
@ -10,4 +10,3 @@
public bool AzureStorageEnabled { get; set; }
}
}

View File

@ -1,6 +1,5 @@
using Microsoft.eShopOnContainers.Services.Catalog.API.Model;
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers;
[Route("api/v1/[controller]")]
[ApiController]
public class CatalogController : ControllerBase
@ -299,4 +298,3 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
return items;
}
}
}

View File

@ -1,7 +1,6 @@
// For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers;
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
{
public class HomeController : Controller
{
// GET: /<controller>/
@ -10,4 +9,3 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
return new RedirectResult("~/swagger");
}
}
}

View File

@ -1,6 +1,6 @@
// For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers;
[ApiController]
public class PicController : ControllerBase
{
@ -84,4 +84,3 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
return mimetype;
}
}
}

View File

@ -1,5 +1,5 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Model
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Model;
public static class CatalogItemExtensions
{
public static void FillProductUrl(this CatalogItem item, string picBaseUrl, bool azureStorageEnabled)
@ -12,4 +12,3 @@
}
}
}
}

View File

@ -1,5 +1,5 @@
namespace Catalog.API.Extensions
{
namespace Catalog.API.Extensions;
public static class HostExtensions
{
public static bool IsInKubernetes(this IHost host)
@ -68,4 +68,3 @@
seeder(context, services);
}
}
}

View File

@ -1,5 +1,5 @@
namespace Catalog.API.Extensions
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Extensions;
public static class LinqSelectExtensions
{
public static IEnumerable<SelectTryResult<TSource, TResult>> SelectTry<TSource, TResult>(this IEnumerable<TSource> enumerable, Func<TSource, TResult> selector)
@ -43,4 +43,3 @@
public Exception CaughtException { get; private set; }
}
}
}

View File

@ -1,5 +1,5 @@
namespace Catalog.API.Extensions
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Extensions;
public static class WebHostExtensions
{
public static bool IsInKubernetes(this IWebHost host)
@ -68,4 +68,3 @@
seeder(context, services);
}
}
}

View File

@ -2,10 +2,10 @@
global using Azure.Identity;
global using Autofac.Extensions.DependencyInjection;
global using Autofac;
global using Catalog.API.Extensions;
global using Catalog.API.Infrastructure.ActionResults;
global using Catalog.API.Infrastructure.Exceptions;
global using global::Catalog.API.IntegrationEvents;
global using Microsoft.eShopOnContainers.Services.Catalog.API.Extensions;
global using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.ActionResults;
global using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.Exceptions;
global using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents;
global using Grpc.Core;
global using Microsoft.AspNetCore.Hosting;
global using Microsoft.AspNetCore.Http;
@ -48,7 +48,7 @@ global using System.Net;
global using System.Text.RegularExpressions;
global using System.Threading.Tasks;
global using System;
global using global::Catalog.API.Infrastructure.Filters;
global using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.Filters;
global using HealthChecks.UI.Client;
global using Microsoft.AspNetCore.Diagnostics.HealthChecks;
global using Microsoft.Azure.ServiceBus;

View File

@ -1,13 +1,13 @@
using CatalogApi;
using static CatalogApi.Catalog;
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Grpc
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Grpc;
public class CatalogService : CatalogBase
{
private readonly CatalogContext _catalogContext;
private readonly CatalogSettings _settings;
private readonly Extensions.Logging.ILogger _logger;
private readonly Microsoft.Extensions.Logging.ILogger _logger;
public CatalogService(CatalogContext dbContext, IOptions<CatalogSettings> settings, ILogger<CatalogService> logger)
{
@ -174,4 +174,3 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Grpc
return items;
}
}
}

View File

@ -1,5 +1,5 @@
namespace Catalog.API.Infrastructure.ActionResults
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.ActionResults;
public class InternalServerErrorObjectResult : ObjectResult
{
public InternalServerErrorObjectResult(object error)
@ -8,4 +8,3 @@
StatusCode = StatusCodes.Status500InternalServerError;
}
}
}

View File

@ -1,7 +1,7 @@
using Microsoft.eShopOnContainers.Services.Catalog.API.Model;
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
public class CatalogContext : DbContext
{
public CatalogContext(DbContextOptions<CatalogContext> options) : base(options)
@ -30,4 +30,3 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure
return new CatalogContext(optionsBuilder.Options);
}
}
}

View File

@ -1,7 +1,7 @@
using Microsoft.eShopOnContainers.Services.Catalog.API.Model;
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
public class CatalogContextSeed
{
public async Task SeedAsync(CatalogContext context, IWebHostEnvironment env, IOptions<CatalogSettings> settings, ILogger<CatalogContextSeed> logger)
@ -368,4 +368,3 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure
);
}
}
}

View File

@ -1,5 +1,5 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.EntityConfigurations
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.EntityConfigurations;
class CatalogBrandEntityTypeConfiguration
: IEntityTypeConfiguration<CatalogBrand>
{
@ -18,4 +18,3 @@
.HasMaxLength(100);
}
}
}

View File

@ -1,5 +1,5 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.EntityConfigurations
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.EntityConfigurations;
class CatalogItemEntityTypeConfiguration
: IEntityTypeConfiguration<CatalogItem>
{
@ -32,4 +32,3 @@
.HasForeignKey(ci => ci.CatalogTypeId);
}
}
}

View File

@ -1,5 +1,5 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.EntityConfigurations
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.EntityConfigurations;
class CatalogTypeEntityTypeConfiguration
: IEntityTypeConfiguration<CatalogType>
{
@ -18,4 +18,3 @@
.HasMaxLength(100);
}
}
}

View File

@ -1,5 +1,5 @@
namespace Catalog.API.Infrastructure.Exceptions
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.Exceptions;
/// <summary>
/// Exception type for app exceptions
/// </summary>
@ -16,4 +16,3 @@
: base(message, innerException)
{ }
}
}

View File

@ -1,5 +1,5 @@
namespace Catalog.API.Infrastructure.Filters
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure.Filters;
public class HttpGlobalExceptionFilter : IExceptionFilter
{
private readonly IWebHostEnvironment env;
@ -56,4 +56,3 @@
public object DeveloperMessage { get; set; }
}
}
}

View File

@ -1,5 +1,5 @@
namespace Catalog.API.IntegrationEvents
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents;
public class CatalogIntegrationEventService : ICatalogIntegrationEventService, IDisposable
{
private readonly Func<DbConnection, IIntegrationEventLogService> _integrationEventLogServiceFactory;
@ -72,4 +72,3 @@
GC.SuppressFinalize(this);
}
}
}

View File

@ -1,5 +1,4 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling;
public class OrderStatusChangedToAwaitingValidationIntegrationEventHandler :
IIntegrationEventHandler<OrderStatusChangedToAwaitingValidationIntegrationEvent>
@ -45,4 +44,3 @@
}
}
}
}

View File

@ -1,5 +1,5 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling;
public class OrderStatusChangedToPaidIntegrationEventHandler :
IIntegrationEventHandler<OrderStatusChangedToPaidIntegrationEvent>
{
@ -33,4 +33,3 @@
}
}
}
}

View File

@ -1,5 +1,5 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events;
public record OrderStatusChangedToAwaitingValidationIntegrationEvent : IntegrationEvent
{
public int OrderId { get; }
@ -24,4 +24,3 @@
Units = units;
}
}
}

View File

@ -1,7 +1,4 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events
{
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
using System.Collections.Generic;
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events;
public record OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent
{
@ -15,4 +12,3 @@
OrderStockItems = orderStockItems;
}
}
}

View File

@ -1,9 +1,8 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events;
public record OrderStockConfirmedIntegrationEvent : IntegrationEvent
{
public int OrderId { get; }
public OrderStockConfirmedIntegrationEvent(int orderId) => OrderId = orderId;
}
}

View File

@ -1,5 +1,5 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events;
public record OrderStockRejectedIntegrationEvent : IntegrationEvent
{
public int OrderId { get; }
@ -25,4 +25,3 @@
HasStock = hasStock;
}
}
}

View File

@ -1,5 +1,5 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events;
// Integration Events notes:
// 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.
@ -18,4 +18,3 @@
OldPrice = oldPrice;
}
}
}

View File

@ -1,8 +1,7 @@
namespace Catalog.API.IntegrationEvents
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents;
public interface ICatalogIntegrationEventService
{
Task SaveEventAndCatalogContextChangesAsync(IntegrationEvent evt);
Task PublishThroughEventBusAsync(IntegrationEvent evt);
}
}

View File

@ -1,9 +1,8 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Model
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Model;
public class CatalogBrand
{
public int Id { get; set; }
public string Brand { get; set; }
}
}

View File

@ -1,5 +1,5 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Model
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Model;
public class CatalogItem
{
public int Id { get; set; }
@ -97,4 +97,3 @@
return this.AvailableStock - original;
}
}
}

View File

@ -1,9 +1,8 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Model
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Model;
public class CatalogType
{
public int Id { get; set; }
public string Type { get; set; }
}
}

View File

@ -1,5 +1,5 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API;
public class Startup
{
public Startup(IConfiguration configuration)
@ -331,4 +331,3 @@
return services;
}
}
}

View File

@ -1,5 +1,5 @@
namespace Microsoft.eShopOnContainers.Services.Catalog.API.ViewModel
{
namespace Microsoft.eShopOnContainers.Services.Catalog.API.ViewModel;
public class PaginatedItemsViewModel<TEntity> where TEntity : class
{
public int PageIndex { get; private set; }
@ -18,4 +18,3 @@
Data = data;
}
}
}