2023-05-16 22:09:57 +03:00
|
|
|
|
using NG_2023_Kanban.DataLayer.Service;
|
2023-05-17 12:36:49 +03:00
|
|
|
|
using NG_2023_Kanban.DataLayer.Repositories;
|
|
|
|
|
using NG_2023_Kanban.DataLayer.Interfaces;
|
2023-05-11 23:20:46 +03:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2023-05-16 22:09:57 +03:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2023-05-11 23:20:46 +03:00
|
|
|
|
|
2023-05-15 20:45:16 +03:00
|
|
|
|
namespace NG_2023_Kanban.DataLayer.DbStartup
|
2023-05-11 23:20:46 +03:00
|
|
|
|
{
|
|
|
|
|
public static class Injecting
|
|
|
|
|
{
|
2023-05-16 22:09:57 +03:00
|
|
|
|
public static void InjectDAL(
|
2023-05-11 23:20:46 +03:00
|
|
|
|
this IServiceCollection services,
|
|
|
|
|
IConfiguration configuration)
|
|
|
|
|
{
|
2023-05-17 12:36:49 +03:00
|
|
|
|
services.AddTransient<IBoardRepository, BoardRepository>();
|
|
|
|
|
services.AddTransient<ICardRepository, CardRepository>();
|
|
|
|
|
services.AddTransient<IColumnRepository, ColumnRepository>();
|
|
|
|
|
services.AddTransient<ICommentRepository, CommentRepository>();
|
|
|
|
|
services.AddTransient<IUserRepository, UserRepository>();
|
|
|
|
|
|
|
|
|
|
var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>();
|
|
|
|
|
|
|
|
|
|
optionsBuilder.UseSqlServer(configuration["ConnectionString"]);
|
|
|
|
|
|
2023-05-11 23:20:46 +03:00
|
|
|
|
services.AddDbContext<DatabaseContext>(options =>
|
|
|
|
|
{
|
|
|
|
|
options.UseSqlServer(
|
|
|
|
|
configuration["ConnectionString"]);
|
|
|
|
|
});
|
2023-05-17 12:36:49 +03:00
|
|
|
|
|
|
|
|
|
(new DatabaseContext(optionsBuilder.Options)).Database.EnsureCreated(); // possibly misplaced
|
2023-05-11 23:20:46 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|