chore: update dependency injection methods of repositories
This commit is contained in:
parent
a9faf74803
commit
30bb3ffa11
@ -33,7 +33,7 @@ try
|
|||||||
// Add services to the container
|
// Add services to the container
|
||||||
var cnn_str = config.GetConnectionString("Default") ?? throw new("Default connection string not found.");
|
var cnn_str = config.GetConnectionString("Default") ?? throw new("Default connection string not found.");
|
||||||
builder.Services.AddDbContext<WFDBContext>(options => options.UseSqlServer(cnn_str).EnableDetailedErrors());
|
builder.Services.AddDbContext<WFDBContext>(options => options.UseSqlServer(cnn_str).EnableDetailedErrors());
|
||||||
builder.Services.AddWorkFlow().AddUserManager<WFDBContext>();
|
builder.Services.AddWorkFlowServices().AddWorkFlowRepositories().AddUserManager<WFDBContext>();
|
||||||
builder.Services.AddCookieBasedLocalizer();
|
builder.Services.AddCookieBasedLocalizer();
|
||||||
builder.Services.AddDirectorySearchService(config.GetSection("DirectorySearchOptions"));
|
builder.Services.AddDirectorySearchService(config.GetSection("DirectorySearchOptions"));
|
||||||
builder.Services.AddJWTService<UserReadDto>(user => new SecurityTokenDescriptor()
|
builder.Services.AddJWTService<UserReadDto>(user => new SecurityTokenDescriptor()
|
||||||
|
|||||||
@ -1,25 +0,0 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
||||||
using WorkFlow.Application.Contracts;
|
|
||||||
using WorkFlow.Application.Services;
|
|
||||||
using WorkFlow.Infrastructure;
|
|
||||||
|
|
||||||
namespace WorkFlow.Application
|
|
||||||
{
|
|
||||||
public static class DIExtensions
|
|
||||||
{
|
|
||||||
public static IServiceCollection AddWorkFlowServices(this IServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddAutoMapper(typeof(MappingProfile).Assembly);
|
|
||||||
services.TryAddScoped<IConfigService, ConfigService>();
|
|
||||||
services.TryAddScoped<IProfileControlsTFService, ProfileControlsTFService>();
|
|
||||||
services.TryAddScoped<IProfileObjStateService, ProfileObjStateService>();
|
|
||||||
services.TryAddScoped<IProfileService, ProfileService>();
|
|
||||||
services.TryAddScoped<IStateService, StateService>();
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IServiceCollection AddWorkFlow(this IServiceCollection services) => services.AddWorkFlowRepositories().AddWorkFlowServices();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
21
src/WorkFlow.Application/DependencyInjection.cs
Normal file
21
src/WorkFlow.Application/DependencyInjection.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
using WorkFlow.Application.Contracts;
|
||||||
|
using WorkFlow.Application.Services;
|
||||||
|
|
||||||
|
namespace WorkFlow.Application;
|
||||||
|
|
||||||
|
public static class DependencyInjection
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddWorkFlowServices(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddAutoMapper(typeof(MappingProfile).Assembly);
|
||||||
|
services.TryAddScoped<IConfigService, ConfigService>();
|
||||||
|
services.TryAddScoped<IProfileControlsTFService, ProfileControlsTFService>();
|
||||||
|
services.TryAddScoped<IProfileObjStateService, ProfileObjStateService>();
|
||||||
|
services.TryAddScoped<IProfileService, ProfileService>();
|
||||||
|
services.TryAddScoped<IStateService, StateService>();
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,20 +0,0 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
||||||
using WorkFlow.Infrastructure.Repositories;
|
|
||||||
|
|
||||||
namespace WorkFlow.Infrastructure
|
|
||||||
{
|
|
||||||
public static class DIExtensions
|
|
||||||
{
|
|
||||||
public static IServiceCollection AddWorkFlowRepositories(this IServiceCollection services)
|
|
||||||
{
|
|
||||||
services.TryAddScoped<IConfigRepository, ConfigRepository>();
|
|
||||||
services.TryAddScoped<IProfileControlsTFRepository, ProfileControlsTFRepository>();
|
|
||||||
services.TryAddScoped<IProfileObjStateRepository, ProfileObjStateRepository>();
|
|
||||||
services.TryAddScoped<IProfileRepository, ProfileRepository>();
|
|
||||||
services.TryAddScoped<IStateRepository, StateRepository>();
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
20
src/WorkFlow.Infrastructure/DependencyInjection.cs
Normal file
20
src/WorkFlow.Infrastructure/DependencyInjection.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
using WorkFlow.Application.Contracts.Repositories;
|
||||||
|
using WorkFlow.Infrastructure.Repositories;
|
||||||
|
|
||||||
|
namespace WorkFlow.Infrastructure;
|
||||||
|
|
||||||
|
public static class DependencyInjection
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddWorkFlowRepositories(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.TryAddScoped<IConfigRepository, ConfigRepository>();
|
||||||
|
services.TryAddScoped<IProfileControlsTFRepository, ProfileControlsTFRepository>();
|
||||||
|
services.TryAddScoped<IProfileObjStateRepository, ProfileObjStateRepository>();
|
||||||
|
services.TryAddScoped<IProfileRepository, ProfileRepository>();
|
||||||
|
services.TryAddScoped<IStateRepository, StateRepository>();
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,8 +3,8 @@ using DigitalData.Core.Infrastructure;
|
|||||||
using WorkFlow.Application.Contracts.Repositories;
|
using WorkFlow.Application.Contracts.Repositories;
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
namespace WorkFlow.Infrastructure.Repositories
|
namespace WorkFlow.Infrastructure.Repositories;
|
||||||
{
|
|
||||||
//TODO: Make the db context type generic so that it can be used by other projects with different db contexts.
|
//TODO: Make the db context type generic so that it can be used by other projects with different db contexts.
|
||||||
public class ConfigRepository : CRUDRepository<Config, int, WFDBContext>, IConfigRepository, ICRUDRepository<Config, int>
|
public class ConfigRepository : CRUDRepository<Config, int, WFDBContext>, IConfigRepository, ICRUDRepository<Config, int>
|
||||||
{
|
{
|
||||||
@ -12,4 +12,3 @@ namespace WorkFlow.Infrastructure.Repositories
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@ -4,8 +4,8 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using WorkFlow.Application.Contracts.Repositories;
|
using WorkFlow.Application.Contracts.Repositories;
|
||||||
using WorkFlow.Domain.Entities;
|
using WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
namespace WorkFlow.Infrastructure.Repositories
|
namespace WorkFlow.Infrastructure.Repositories;
|
||||||
{
|
|
||||||
public class ProfileControlsTFRepository : CRUDRepository<ProfileControlsTF, int, WFDBContext>, IProfileControlsTFRepository, ICRUDRepository<ProfileControlsTF, int>
|
public class ProfileControlsTFRepository : CRUDRepository<ProfileControlsTF, int, WFDBContext>, IProfileControlsTFRepository, ICRUDRepository<ProfileControlsTF, int>
|
||||||
{
|
{
|
||||||
public ProfileControlsTFRepository(WFDBContext dbContext) : base(dbContext, dbContext.ProfileControlsTFs)
|
public ProfileControlsTFRepository(WFDBContext dbContext) : base(dbContext, dbContext.ProfileControlsTFs)
|
||||||
@ -51,4 +51,3 @@ namespace WorkFlow.Infrastructure.Repositories
|
|||||||
profileId: profileId, objId: objId)
|
profileId: profileId, objId: objId)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user