﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using SWFramework.DDD.UnitOfWorkRepository;
using SWFramework.DDD;
using BlogDream.Domain.Infrastructure;

namespace BlogDream.Domain.Infrastructure.Repository
{
    public static class DBServiceCollectionExtensions
    {
        public static IServiceCollection AddDBConfig(this IServiceCollection service, string config)
        {
            return service;
        }

        public static IServiceCollection AddUnitOfWorkRepository(this IServiceCollection service, string connStr)
        {
            return service
                .AddScoped<IUnitOfWorkRepository, BlogUnitOfWorkRepository>(_ =>
                {
                    return new BlogUnitOfWorkRepository(new BlogDBContext(connStr));
                });
        }
    }
}