Merge pull request #1924 from Ich1goSan/feature/minor-refactoring

Minor refactoring
This commit is contained in:
Tarun Jain 2022-07-25 23:11:49 +05:30 committed by GitHub
commit 12ee00d660
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 17 additions and 45 deletions

View File

@ -242,11 +242,11 @@ public class Startup
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>(); var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>(); var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>(); var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubscriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
string subscriptionName = Configuration["SubscriptionClientName"]; string subscriptionName = Configuration["SubscriptionClientName"];
return new EventBusServiceBus(serviceBusPersisterConnection, logger, return new EventBusServiceBus(serviceBusPersisterConnection, logger,
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName); eventBusSubscriptionsManager, iLifetimeScope, subscriptionName);
}); });
} }
else else
@ -257,7 +257,7 @@ public class Startup
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>(); var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>(); var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>(); var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>(); var eventBusSubscriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
var retryCount = 5; var retryCount = 5;
if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"])) if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"]))
@ -265,7 +265,7 @@ public class Startup
retryCount = int.Parse(Configuration["EventBusRetryCount"]); retryCount = int.Parse(Configuration["EventBusRetryCount"]);
} }
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount); return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubscriptionsManager, subscriptionClientName, retryCount);
}); });
} }

View File

@ -4,15 +4,14 @@
{ {
public string ExtractRedirectUriFromReturnUrl(string url) public string ExtractRedirectUriFromReturnUrl(string url)
{ {
var result = "";
var decodedUrl = System.Net.WebUtility.HtmlDecode(url); var decodedUrl = System.Net.WebUtility.HtmlDecode(url);
var results = Regex.Split(decodedUrl, "redirect_uri="); var results = Regex.Split(decodedUrl, "redirect_uri=");
if (results.Length < 2) if (results.Length < 2)
return ""; return "";
result = results[1]; string result = results[1];
var splitKey = ""; string splitKey;
if (result.Contains("signin-oidc")) if (result.Contains("signin-oidc"))
splitKey = "signin-oidc"; splitKey = "signin-oidc";
else else

View File

@ -35,7 +35,7 @@ public class TransactionBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequ
{ {
Guid transactionId; Guid transactionId;
using var transaction = await _dbContext.BeginTransactionAsync(); await using var transaction = await _dbContext.BeginTransactionAsync();
using (LogContext.PushProperty("TransactionContext", transaction.TransactionId)) using (LogContext.PushProperty("TransactionContext", transaction.TransactionId))
{ {
_logger.LogInformation("----- Begin transaction {TransactionId} for {CommandName} ({@Command})", transaction.TransactionId, typeName, request); _logger.LogInformation("----- Begin transaction {TransactionId} for {CommandName} ({@Command})", transaction.TransactionId, typeName, request);

View File

@ -134,8 +134,7 @@ static class CustomExtensionsMethods
}) })
// Added for functional tests // Added for functional tests
.AddApplicationPart(typeof(OrdersController).Assembly) .AddApplicationPart(typeof(OrdersController).Assembly)
.AddJsonOptions(options => options.JsonSerializerOptions.WriteIndented = true) .AddJsonOptions(options => options.JsonSerializerOptions.WriteIndented = true);
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
services.AddCors(options => services.AddCors(options =>
{ {

View File

@ -4,7 +4,6 @@ global using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
global using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate; global using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
global using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate; global using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
global using Microsoft.eShopOnContainers.Services.Ordering.Domain.Events; global using Microsoft.eShopOnContainers.Services.Ordering.Domain.Events;
global using Microsoft.eShopOnContainers.Services.Ordering.Domain.Exceptions;
global using System.Collections.Generic; global using System.Collections.Generic;
global using System.Linq; global using System.Linq;
global using System.Reflection; global using System.Reflection;

View File

@ -10,8 +10,4 @@
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.7.0" /> <PackageReference Include="System.Reflection.TypeExtensions" Version="4.7.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project> </Project>

View File

@ -16,8 +16,4 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project> </Project>

View File

@ -72,7 +72,7 @@ public class OrderingContext : DbContext, IUnitOfWork
try try
{ {
await SaveChangesAsync(); await SaveChangesAsync();
transaction.Commit(); await transaction.CommitAsync();
} }
catch catch
{ {
@ -128,7 +128,7 @@ public class OrderingContextDesignFactory : IDesignTimeDbContextFactory<Ordering
return default(IAsyncEnumerable<object?>); return default(IAsyncEnumerable<object?>);
} }
public Task Publish<TNotification>(TNotification notification, CancellationToken cancellationToken = default(CancellationToken)) where TNotification : INotification public Task Publish<TNotification>(TNotification notification, CancellationToken cancellationToken = default) where TNotification : INotification
{ {
return Task.CompletedTask; return Task.CompletedTask;
} }
@ -138,7 +138,7 @@ public class OrderingContextDesignFactory : IDesignTimeDbContextFactory<Ordering
return Task.CompletedTask; return Task.CompletedTask;
} }
public Task<TResponse> Send<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken = default(CancellationToken)) public Task<TResponse> Send<TResponse>(IRequest<TResponse> request, CancellationToken cancellationToken = default)
{ {
return Task.FromResult<TResponse>(default(TResponse)); return Task.FromResult<TResponse>(default(TResponse));
} }

View File

@ -19,11 +19,9 @@ public class BuyerRepository
.Add(buyer) .Add(buyer)
.Entity; .Entity;
} }
else
{
return buyer; return buyer;
} }
}
public Buyer Update(Buyer buyer) public Buyer Update(Buyer buyer)
{ {

View File

@ -22,8 +22,6 @@ global using Microsoft.Extensions.Diagnostics.HealthChecks;
global using Microsoft.Extensions.Logging; global using Microsoft.Extensions.Logging;
global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.AutofacModules; global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.AutofacModules;
global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling; global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling;
global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.Events;
global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents;
global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub; global using Microsoft.eShopOnContainers.Services.Ordering.SignalrHub;
global using RabbitMQ.Client; global using RabbitMQ.Client;
global using Serilog.Context; global using Serilog.Context;

View File

@ -7,10 +7,6 @@
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled> <IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="5.1.1" /> <PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="5.1.1" />
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" /> <PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="5.0.1" />

View File

@ -52,9 +52,6 @@ public class WebhooksController : ControllerBase
return ValidationProblem(ModelState); return ValidationProblem(ModelState);
} }
var userId = _identityService.GetUserIdentity();
var grantOk = await _grantUrlTester.TestGrantUrl(request.Url, request.GrantUrl, request.Token ?? string.Empty); var grantOk = await _grantUrlTester.TestGrantUrl(request.Url, request.GrantUrl, request.Token ?? string.Empty);
if (grantOk) if (grantOk)

View File

@ -22,8 +22,6 @@ public class Startup
IdentityModelEventSource.ShowPII = true; // Caution! Do NOT use in production: https://aka.ms/IdentityModel/PII IdentityModelEventSource.ShowPII = true; // Caution! Do NOT use in production: https://aka.ms/IdentityModel/PII
services.AddControllers();
services.AddCustomAuthentication(Configuration); services.AddCustomAuthentication(Configuration);
} }

View File

@ -14,7 +14,7 @@ public class Startup
{ {
RegisterAppInsights(services); RegisterAppInsights(services);
services.AddControllers(); services.AddMvc();
services.AddOptions(); services.AddOptions();
services.AddHealthChecks() services.AddHealthChecks()
@ -23,9 +23,6 @@ public class Startup
services services
.AddHealthChecksUI() .AddHealthChecksUI()
.AddInMemoryStorage(); .AddInMemoryStorage();
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

View File

@ -21,8 +21,7 @@ public class Startup
.AddCustomAuthentication(Configuration) .AddCustomAuthentication(Configuration)
.AddTransient<IWebhooksClient, WebhooksClient>() .AddTransient<IWebhooksClient, WebhooksClient>()
.AddSingleton<IHooksRepository, InMemoryHooksRepository>() .AddSingleton<IHooksRepository, InMemoryHooksRepository>()
.AddMvc() .AddMvc();
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
services.AddControllers(); services.AddControllers();
} }