Skip to content

Commit

Permalink
created module Startup files
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidEggenberger committed Dec 29, 2023
1 parent 88e639f commit a9b4f73
Show file tree
Hide file tree
Showing 42 changed files with 322 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class AddMessageToChannelCommand : ICommand
}
public class AddMessageToChannelCommandHandler : ICommandHandler<AddMessageToChannelCommand>
{
private readonly ChannelDbContext applicationDbContext;
public AddMessageToChannelCommandHandler(ChannelDbContext applicationDbContext)
private readonly ChannelsDbContext applicationDbContext;
public AddMessageToChannelCommandHandler(ChannelsDbContext applicationDbContext)
{
this.applicationDbContext = applicationDbContext;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class ChangeChannelNameCommand : ICommand

public class ChangeChannelNameCommandHandler : ICommandHandler<ChangeChannelNameCommand>
{
private readonly ChannelDbContext applicationDbContext;
public ChangeChannelNameCommandHandler(ChannelDbContext applicationDbContext)
private readonly ChannelsDbContext applicationDbContext;
public ChangeChannelNameCommandHandler(ChannelsDbContext applicationDbContext)
{
this.applicationDbContext = applicationDbContext;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class CreateChannelCommand : ICommand
}
public class CreateChannelCommandHandler : ICommandHandler<CreateChannelCommand>
{
private readonly ChannelDbContext applicationDbContext;
private readonly ChannelsDbContext applicationDbContext;
private readonly ITenantResolver teamResolver;
public CreateChannelCommandHandler(ChannelDbContext applicationDbContext, ITenantResolver teamResolver)
public CreateChannelCommandHandler(ChannelsDbContext applicationDbContext, ITenantResolver teamResolver)
{
this.applicationDbContext = applicationDbContext;
this.teamResolver = teamResolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public class DeleteChannelCommand : ICommand
}
public class DeleteChannelCommandCommandHandler : ICommandHandler<DeleteChannelCommand>
{
private readonly ChannelDbContext applicationDbContext;
private readonly ChannelsDbContext applicationDbContext;
private readonly ITenantResolver teamResolver;
public DeleteChannelCommandCommandHandler(ChannelDbContext applicationDbContext, ITenantResolver teamResolver)
public DeleteChannelCommandCommandHandler(ChannelsDbContext applicationDbContext, ITenantResolver teamResolver)
{
this.applicationDbContext = applicationDbContext;
this.teamResolver = teamResolver;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Modules.Channels.Features.ChannelAggregate.Events;
using Shared.Features.CQRS.DomainEvent;

namespace Modules.Channels.Features.ChannelAggregate.Application.EventHandlers
{
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Modules.Channels.Features.Infrastructure.EFCore
{
public class ChannelDbContext : BaseDbContext<ChannelDbContext>
public class ChannelsDbContext : BaseDbContext<ChannelsDbContext>
{
public ChannelDbContext(DbContextOptions<ChannelDbContext> dbContextOptions, IServiceProvider serviceProvider, IConfiguration configuration) : base(dbContextOptions, serviceProvider, configuration)
public ChannelsDbContext(DbContextOptions<ChannelsDbContext> dbContextOptions, IServiceProvider serviceProvider, IConfiguration configuration) : base(dbContextOptions, serviceProvider, configuration)
{

}
Expand Down
28 changes: 28 additions & 0 deletions Source/Modules/Channels/Web/Server/ChannelsModuleStartup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Modules.Channels.Features.Infrastructure.EFCore;
using Shared.Features.Modules;
using System.Reflection;
using Shared.Features.EFCore;

namespace Modules.Channels.Web.Server
{
public class ChannelsModuleStartup : IModuleStartup
{
public Assembly FeaturesAssembly { get; } = typeof(ChannelsModuleStartup).Assembly;
public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddControllers().AddApplicationPart(typeof(ChannelsModuleStartup).Assembly);
services.AddSignalR();

services.RegisterDbContext<ChannelsDbContext>("Contacts");
}

public void Configure(IApplicationBuilder app, IHostEnvironment env)
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<ProjectReference Include="..\..\..\..\Shared\Shared.Infrastructure\Shared.Features.csproj" />
<ProjectReference Include="..\..\..\..\Shared\Shared.Kernel\Shared.Kernel.csproj" />
<ProjectReference Include="..\..\Features\Modules.Channels.Features.csproj" />
<ProjectReference Include="..\..\Features\Modules.Channelss.Features.csproj" />
<ProjectReference Include="..\DTOs\Modules.Channels.Web.Shared.csproj" />
</ItemGroup>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Shared.Features.Modules;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Modules.LandingPages.Server
{
public class LandingPagesModuleStartup : IModuleStartup
{
public Assembly FeaturesAssembly { get; } = typeof(LandingPagesModuleStartup).Assembly;
public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddRazorPages()
.AddApplicationPart(typeof(LandingPagesModuleStartup).Assembly);
}

public void Configure(IApplicationBuilder app, IHostEnvironment env)
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\Shared\Shared.Infrastructure\Shared.Features.csproj" />
</ItemGroup>



</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace WebServer.Controllers.Stripe
namespace Modules.Subscriptions.Web.Server.Controllers
{
[Route("api/[controller]")]
[ApiController]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\Shared\Shared.Features\Shared.Features.csproj" />
<ProjectReference Include="..\..\..\..\Shared\Shared.Infrastructure\Shared.Features.csproj" />
<ProjectReference Include="..\..\Features\Modules.Subscription.Features\Modules.Subscriptions.Features.csproj" />
</ItemGroup>

</Project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Shared.Features.Modules;
using Stripe;
using System.Reflection;

namespace Modules.Subscriptions.Web.Server
{
public class SubscriptionsModuleStartup : IModuleStartup
{
public Assembly FeaturesAssembly { get; } = typeof(SubscriptionsModuleStartup).Assembly;
public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
StripeConfiguration.ApiKey = configuration["Stripe:StripeKey"];
//services.Configure<StripeOptions>(configuration);
//services.AddScoped<IStripeSubscriptionService, StripeSubscriptionTypeService>();

services.AddControllers()
.AddApplicationPart(typeof(SubscriptionsModuleStartup).Assembly);
}

public void Configure(IApplicationBuilder app, IHostEnvironment env)
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\Shared\Shared.Features\Shared.Features.csproj" />
<ProjectReference Include="..\..\..\..\Shared\Shared.Infrastructure\Shared.Features.csproj" />
<ProjectReference Include="..\DTOs\Modules.TenantIdentity.Web.Shared.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Shared.Features.Modules;
using Shared.Kernel.BuildingBlocks.Authorization.Services;
using Shared.SharedKernel.Constants;
using System.Reflection;
using System.Security.Claims;


namespace Shared.Modules.Layers.Features.Identity
namespace Modules.TenantIdentity.Web.Server
{
public static class TenantIdentityRegistrator
public class TenantIdentityModuleStartup : IModuleStartup
{
public static IServiceCollection RegisterIdentity(this IServiceCollection services, IConfiguration configuration)
public Assembly FeaturesAssembly { get; } = typeof(TenantIdentityModuleStartup).Assembly;
public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
services.AddControllers().AddApplicationPart(typeof(TenantIdentityModuleStartup).Assembly);
services.AddSignalR();

services.AddSingleton<OpenIdConnectPostConfigureOptions>();
//services.AddScoped<IUserResolver, UserResolver>();

Expand Down Expand Up @@ -109,8 +117,11 @@ public static IServiceCollection RegisterIdentity(this IServiceCollection servic
.AddSignInManager();

services.AddScoped<IUserAuthorizationService, UserAuthorizationService>();
}

public void Configure(IApplicationBuilder app, IHostEnvironment env)
{

return services;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using System.Reflection;
using Shared.Features.CQRS.Command;
using Shared.Features.CQRS.Features.DomainKernelEvent;

namespace Shared.Features.CQRS
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using Shared.Features.DomainKernel.Interfaces;

namespace Shared.Features.CQRS.Features.DomainKernelEvent
namespace Shared.Features.CQRS.DomainEvent
{
public class DomainEventDispatcher : IDomainEventDispatcher
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Shared.Features.DomainKernel.Interfaces;

namespace Shared.Features.CQRS.Features.DomainKernelEvent
namespace Shared.Features.CQRS.DomainEvent
{
public interface IDomainEventDispatcher
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Shared.Features.DomainKernel.Interfaces;

namespace Shared.Features.CQRS.Features.DomainKernelEvent
namespace Shared.Features.CQRS.DomainEvent
{
public interface IDomainEventHandler<in TDomainEvent> where TDomainEvent : IDomainEvent
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Shared.Features.DomainKernel;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Shared.Features.MultiTenancy.EFCore;
using Shared.Features.CQRS.Features.DomainKernelEvent;
using Shared.Kernel.BuildingBlocks.Authorization.Services;

namespace Shared.Features.EFCore
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Shared.Features.EFCore.Configuration
{
public class EFCoreConfiguration
{
public string SQLServerConnectionString { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Shared.Features.EFCore.Configuration
{
public class EFCoreConfigurationConstants
{
public const string DevelopmentSQLServerConnectionString = nameof(DevelopmentSQLServerConnectionString);
public const string ProductionSQLServerConnectionString = nameof(ProductionSQLServerConnectionString);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;

namespace Shared.Features.EFCore.Configuration
{
public static class EFCoreConfigurationRegistrator
{
public static IServiceCollection RegisterEFCore(this IServiceCollection services, IConfiguration configuration)
{
services.AddScoped(sp =>
{
EFCoreConfiguration tc = new EFCoreConfiguration();
configuration.GetSection(nameof(EFCoreConfiguration)).Bind(tc);
return tc;
});
services.Configure<EFCoreConfiguration>(configuration.GetSection(nameof(EFCoreConfiguration)));
services.AddSingleton<IValidateOptions<EFCoreConfiguration>, EFCoreConfigurationValidator>();

return services;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.Extensions.Options;

namespace Shared.Features.EFCore.Configuration
{
internal class EFCoreConfigurationValidator : IValidateOptions<EFCoreConfiguration>
{
public ValidateOptionsResult Validate(string name, EFCoreConfiguration efCoreConfiguration)
{
//if (string.IsNullOrEmpty(efCoreConfiguration.SQLServerConnectionString))
//{
// return ValidateOptionsResult.Fail("");
//}

return ValidateOptionsResult.Success;
}
}
}
Loading

0 comments on commit a9b4f73

Please sign in to comment.