mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
ConfigurationProgramExtensions
This commit is contained in:
@@ -0,0 +1,57 @@
|
|||||||
|
using Govor.API.Services;
|
||||||
|
using Govor.API.Services.AdminsStuff;
|
||||||
|
using Govor.API.Services.AdminsStuff.Interfaces;
|
||||||
|
using Govor.API.Services.Authentication;
|
||||||
|
using Govor.API.Services.Authentication.Interfaces;
|
||||||
|
using Govor.Core.Infrastructure.Extensions;
|
||||||
|
using Govor.Core.Infrastructure.Validators;
|
||||||
|
using Govor.Core.Models;
|
||||||
|
using Govor.Core.Repositories.Admins;
|
||||||
|
using Govor.Core.Repositories.Invaites;
|
||||||
|
using Govor.Core.Repositories.MediasAttachments;
|
||||||
|
using Govor.Core.Repositories.Messages;
|
||||||
|
using Govor.Core.Repositories.Users;
|
||||||
|
using Govor.Data;
|
||||||
|
using Govor.Data.Repositories;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace Govor.API.Extensions;
|
||||||
|
|
||||||
|
public static class ConfigurationProgramExtensions
|
||||||
|
{
|
||||||
|
public static void AddServices(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddScoped<IPasswordHasher, PasswordHasher>();
|
||||||
|
services.AddScoped<IJwtService, JwtService>();
|
||||||
|
services.AddScoped<IAccountService, AuthService>();
|
||||||
|
services.AddScoped<IUsersAdministration, UsersService>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddRepositories(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddScoped<IUsersRepository, UsersRepository>();
|
||||||
|
services.AddScoped<IMessagesRepository, MessagesRepository>();
|
||||||
|
services.AddScoped<IInvitesRepository, InvitesRepository>();
|
||||||
|
services.AddScoped<IAdminsRepository, AdminsRepository>();
|
||||||
|
services.AddScoped<IMediaAttachmentsRepository, MediaAttachmentsRepository>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddValidators(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddScoped<IObjectValidator<User>, UserValidator>();
|
||||||
|
services.AddScoped<IObjectValidator<Message>, MessageValidator>();
|
||||||
|
services.AddScoped<IObjectValidator<MediaAttachments>, MediaAttachmentsValidator>();
|
||||||
|
services.AddScoped<IObjectValidator<Admin>, AdminValidator>();
|
||||||
|
services.AddScoped<IObjectValidator<Invitation>, InvitationValidator>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddGovorDbContext(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
services.AddDbContext<GovorDbContext>(
|
||||||
|
options =>
|
||||||
|
{
|
||||||
|
options.UseNpgsql(configuration.GetConnectionString(nameof(GovorDbContext)));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
-18
@@ -1,5 +1,6 @@
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Govor.API.Extensions;
|
||||||
using Govor.API.Hubs;
|
using Govor.API.Hubs;
|
||||||
using Govor.API.Services;
|
using Govor.API.Services;
|
||||||
using Govor.API.Services.AdminsStuff;
|
using Govor.API.Services.AdminsStuff;
|
||||||
@@ -75,25 +76,12 @@ builder.Services.AddAuthorization();
|
|||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
|
|
||||||
builder.Services.AddScoped<IPasswordHasher, PasswordHasher>();
|
// Init DI
|
||||||
builder.Services.AddScoped<IJwtService, JwtService>();
|
builder.Services.AddServices();
|
||||||
builder.Services.AddScoped<IAccountService, AuthService>();
|
builder.Services.AddRepositories();
|
||||||
builder.Services.AddScoped<IUsersRepository, UsersRepository>();
|
builder.Services.AddValidators();
|
||||||
builder.Services.AddScoped<IObjectValidator<User>, UserValidator>();
|
|
||||||
builder.Services.AddScoped<IObjectValidator<Message>, MessageValidator>();
|
|
||||||
builder.Services.AddScoped<IObjectValidator<MediaAttachments>, MediaAttachmentsValidator>();
|
|
||||||
builder.Services.AddScoped<IMessagesRepository, MessagesRepository>();
|
|
||||||
builder.Services.AddScoped<IMediaAttachmentsRepository, MediaAttachmentsRepository>();
|
|
||||||
builder.Services.AddScoped<IUsersAdministration, UsersService>();
|
|
||||||
builder.Services.AddScoped<IInvitesRepository, InvitesRepository>();
|
|
||||||
builder.Services.AddScoped<IAdminsRepository, AdminsRepository>();
|
|
||||||
|
|
||||||
builder.Services.AddDbContext<GovorDbContext>(
|
builder.Services.AddGovorDbContext(configuration); // GovorDbContext init
|
||||||
options =>
|
|
||||||
{
|
|
||||||
options.UseNpgsql(builder.Configuration.GetConnectionString(nameof(GovorDbContext)));
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ public class Invitation
|
|||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public bool IsAdmin { get; set; }
|
public bool IsAdmin { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
public DateTime DateCreated { get; set; }
|
public DateTime DateCreated { get; set; }
|
||||||
public DateTime EndDate { get; set; }
|
public DateTime EndDate { get; set; }
|
||||||
public int MaxParticipants { get; set; }
|
public int MaxParticipants { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user