Skip to content

Commit

Permalink
Merge pull request #136 from loresoft/develop
Browse files Browse the repository at this point in the history
upgrade
  • Loading branch information
pwelter34 authored Dec 28, 2022
2 parents dc3cc03 + d3fed68 commit 950c427
Show file tree
Hide file tree
Showing 40 changed files with 356 additions and 216 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
- name: Setup .NET 7.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x

- name: Setup MSBuild
uses: microsoft/[email protected]
Expand All @@ -49,14 +49,14 @@ jobs:

- name: Upload WebApplication Artifact
if: success()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: WebApplication
path: '${{env.BUILD_PATH}}/WebApplication'

- name: Upload Database Artifact
if: success()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: Database
path: '${{env.BUILD_PATH}}/Database'
Expand All @@ -68,7 +68,7 @@ jobs:

steps:
- name: Download Web Application Artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: WebApplication

Expand Down Expand Up @@ -97,22 +97,22 @@ jobs:

steps:
- name: Download Database Artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: Database

- name: Deploy SQL Server Database to Azure Staging
if: github.ref == 'refs/heads/develop'
uses: azure/sql-action@v1
uses: azure/sql-action@v2
with:
server-name: ${{secrets.AZURE_SQL_SERVER}}
connection-string: ${{secrets.AZURE_SQL_CONNECTION_STAGING}}
dacpac-package: './InstructorIQ.dacpac'
path: './InstructorIQ.dacpac'
action: 'publish'

- name: Deploy SQL Server Database to Azure Production
if: github.ref == 'refs/heads/master'
uses: azure/sql-action@v1
uses: azure/sql-action@v2
with:
server-name: ${{secrets.AZURE_SQL_SERVER}}
connection-string: ${{secrets.AZURE_SQL_CONNECTION_PRODUCTION}}
dacpac-package: './InstructorIQ.dacpac'
path: './InstructorIQ.dacpac'
action: 'publish'
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Threading;
using System.Threading;
using System.Threading.Tasks;

using MediatR;
using MediatR.CommandQuery.Behaviors;
using MediatR.CommandQuery.Commands;

using Microsoft.Extensions.Logging;

namespace InstructorIQ.Core.Behaviors
Expand All @@ -14,10 +16,10 @@ public AuthenticateEntityIdentifierCommandBehavior(ILoggerFactory loggerFactory)
{
}

protected override async Task<TReadModel> Process(EntityIdentifierCommand<TKey, TReadModel> request, CancellationToken cancellationToken, RequestHandlerDelegate<TReadModel> next)
protected override async Task<TReadModel> Process(EntityIdentifierCommand<TKey, TReadModel> request, RequestHandlerDelegate<TReadModel> next, CancellationToken cancellationToken)
{
// continue pipeline
return await next().ConfigureAwait(false);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Threading;
using System.Threading;
using System.Threading.Tasks;

using MediatR;
using MediatR.CommandQuery.Behaviors;
using MediatR.CommandQuery.Commands;

using Microsoft.Extensions.Logging;

namespace InstructorIQ.Core.Behaviors
Expand All @@ -14,11 +16,11 @@ public TrackChangeEntityPatchCommandBehavior(ILoggerFactory loggerFactory) : bas
{
}

protected override async Task<TReadModel> Process(EntityPatchCommand<TKey, TReadModel> request, CancellationToken cancellationToken, RequestHandlerDelegate<TReadModel> next)
protected override async Task<TReadModel> Process(EntityPatchCommand<TKey, TReadModel> request, RequestHandlerDelegate<TReadModel> next, CancellationToken cancellationToken)
{
// continue pipeline
return await next().ConfigureAwait(false);
}

}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Threading;
using System.Threading;
using System.Threading.Tasks;

using MediatR;
using MediatR.CommandQuery.Behaviors;
using MediatR.CommandQuery.Commands;

using Microsoft.Extensions.Logging;

namespace InstructorIQ.Core.Behaviors
Expand All @@ -14,10 +16,10 @@ public TrackChangeEntityUpdateCommandBehavior(ILoggerFactory loggerFactory) : ba
{
}

protected override async Task<TReadModel> Process(EntityUpdateCommand<TKey, TUpdateModel, TReadModel> request, CancellationToken cancellationToken, RequestHandlerDelegate<TReadModel> next)
protected override async Task<TReadModel> Process(EntityUpdateCommand<TKey, TUpdateModel, TReadModel> request, RequestHandlerDelegate<TReadModel> next, CancellationToken cancellationToken)
{
// continue pipeline
return await next().ConfigureAwait(false);
}
}
}
}
35 changes: 19 additions & 16 deletions service/src/InstructorIQ.Core/Data/DataServiceModule.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using FluentCommand;
using InstructorIQ.Core.Options;
using KickStart.DependencyInjection;

using Injectio.Attributes;

using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
Expand All @@ -10,23 +10,26 @@

namespace InstructorIQ.Core.Data
{
public class DataServiceModule : IDependencyInjectionRegistration
public class DataServiceModule
{
public void Register(IServiceCollection services, IDictionary<string, object> data)
{
data.TryGetValue(ConfigurationServiceModule.ConfigurationKey, out var configurationData);

if (!(configurationData is IConfiguration configuration))
return;

var connectionString = configuration.GetConnectionString("InstructorIQ");
[RegisterServices]
public void Register(IServiceCollection services)
{
services.AddDbContextPool<InstructorIQContext>((provider, options) =>
{
var configuration = provider.GetRequiredService<IConfiguration>();
var connectionString = configuration.GetConnectionString("InstructorIQ");
options.UseSqlServer(connectionString, providerOptions => providerOptions.EnableRetryOnFailure());
});

services.AddDbContext<InstructorIQContext>(
options => options.UseSqlServer(connectionString, providerOptions => providerOptions.EnableRetryOnFailure()),
ServiceLifetime.Transient
);
services.TryAddSingleton<IDataConfiguration>(provider =>
{
var configuration = provider.GetRequiredService<IConfiguration>();
var connectionString = configuration.GetConnectionString("InstructorIQ");
return new DataConfiguration(SqlClientFactory.Instance, connectionString);
});

services.TryAddSingleton<IDataConfiguration>(s => new DataConfiguration(SqlClientFactory.Instance, connectionString));
services.TryAddTransient<IDataSession, DataSession>();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
using System;
using System;
using System.Collections.Generic;

using Injectio.Attributes;

using InstructorIQ.Core.Data.Entities;
using InstructorIQ.Core.Domain.Handlers;
using InstructorIQ.Core.Domain.Models;
using InstructorIQ.Core.Domain.Queries;

using MediatR;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;

Expand All @@ -13,7 +18,8 @@ namespace InstructorIQ.Core.Domain
{
public class AttendanceServiceRegistration : DomainServiceRegistrationBase
{
public override void Register(IServiceCollection services, IDictionary<string, object> data)
[RegisterServices]
public override void Register(IServiceCollection services)
{
RegisterEntityQuery<Guid, Attendance, AttendanceReadModel>(services);
RegisterEntityQuery<Guid, Attendance, AttendanceSessionModel>(services);
Expand All @@ -24,4 +30,4 @@ public override void Register(IServiceCollection services, IDictionary<string, o
services.TryAddTransient<IRequestHandler<AttendanceSessionQuery, IReadOnlyCollection<AttendanceSessionModel>>, AttendanceSessionQueryHandler>();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;

using Injectio.Attributes;

using InstructorIQ.Core.Domain.Models;

using Microsoft.Extensions.DependencyInjection;

// ReSharper disable once CheckNamespace
namespace InstructorIQ.Core.Domain
{
public class AuthenticationEventServiceRegistration : DomainServiceRegistrationBase
{
public override void Register(IServiceCollection services, IDictionary<string, object> data)

[RegisterServices]
public override void Register(IServiceCollection services)
{
RegisterEntityQuery<Guid, InstructorIQ.Core.Data.Entities.AuthenticationEvent, AuthenticationEventReadModel>(services);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
using System.Collections.Generic;
using AutoMapper;
using Injectio.Attributes;

using InstructorIQ.Core.Data;
using KickStart.DependencyInjection;

using MediatR.CommandQuery.Audit;
using MediatR.CommandQuery.EntityFrameworkCore;

using Microsoft.Extensions.DependencyInjection;

namespace InstructorIQ.Core.Domain
{
public class CommandQueryServiceModule : IDependencyInjectionRegistration

public class CommandQueryServiceModule
{
public void Register(IServiceCollection services, IDictionary<string, object> data)

[RegisterServices]
public void Register(IServiceCollection services)
{
services.AddMediator();
services.AddAutoMapper(typeof(InstructorIQContext).Assembly);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
using System;
using System;
using System.Collections.Generic;

using Injectio.Attributes;

using InstructorIQ.Core.Data.Entities;
using InstructorIQ.Core.Domain.Handlers;
using InstructorIQ.Core.Domain.Models;
using InstructorIQ.Core.Domain.Queries;

using MediatR;
using MediatR.CommandQuery.Audit;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;

Expand All @@ -14,7 +19,9 @@ namespace InstructorIQ.Core.Domain
{
public class DiscussionServiceRegistration : DomainServiceRegistrationBase
{
public override void Register(IServiceCollection services, IDictionary<string, object> data)

[RegisterServices]
public override void Register(IServiceCollection services)
{
RegisterEntityQuery<Guid, Discussion, DiscussionReadModel>(services);
RegisterEntityCommand<Guid, Discussion, DiscussionReadModel, DiscussionCreateModel, DiscussionUpdateModel>(services);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System.Collections.Generic;

using InstructorIQ.Core.Behaviors;
using InstructorIQ.Core.Data;

using KickStart.DependencyInjection;

using MediatR;
using MediatR.CommandQuery.Commands;
using MediatR.CommandQuery.Definitions;
Expand All @@ -14,9 +10,10 @@

namespace InstructorIQ.Core.Domain
{
public abstract class DomainServiceRegistrationBase : IDependencyInjectionRegistration
public abstract class DomainServiceRegistrationBase
{
public abstract void Register(IServiceCollection services, IDictionary<string, object> data);

public abstract void Register(IServiceCollection services);

protected virtual void RegisterEntityCommand<TKey, TEntity, TReadModel, TCreateModel, TUpdateModel>(IServiceCollection services)
where TEntity : class, IHaveIdentifier<TKey>, new()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using System;

using Injectio.Attributes;

using InstructorIQ.Core.Data.Entities;
using InstructorIQ.Core.Domain.Commands;
using InstructorIQ.Core.Domain.Handlers;
using InstructorIQ.Core.Domain.Models;

using MediatR;
using MediatR.CommandQuery.Models;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;

// ReSharper disable once CheckNamespace
namespace InstructorIQ.Core.Domain
{
public class EmailDeliveryServiceRegistration : DomainServiceRegistrationBase
{
public override void Register(IServiceCollection services, IDictionary<string, object> data)

[RegisterServices]
public override void Register(IServiceCollection services)
{
RegisterEntityQuery<Guid, EmailDelivery, EmailDeliveryReadModel>(services);

Expand All @@ -23,4 +29,4 @@ public override void Register(IServiceCollection services, IDictionary<string, o
services.TryAddTransient<IRequestHandler<SendSummaryEmailCommand, CompleteModel>, SendSummaryEmailCommandHandler>();
}
}
}
}
Loading

0 comments on commit 950c427

Please sign in to comment.