using LSFE.Domain.Contracts;
using LSFE.Domain.Contracts.Doctor;
using LSFE.Domain.Contracts.Maintenance;
using LSFE.Domain.Contracts.Planning;
using LSFE.Domain.Contracts.Reports;
using LSFE.Domain.Contracts.TimeKeeping;
using LSFE.Domain.Services.Doctor;
using LSFE.Domain.Services.Maintenance;
using LSFE.Domain.Services.Planning;
using LSFE.Domain.Services.Reports;
using LSFE.Domain.Services.TimeKeeping;
using LSFE.Infrastructure.Database;
using LSFE.Infrastructure.Entities.Admin;
using LSFE.Infrastructure.Entities.Doctor;
using LSFE.Infrastructure.Entities.Maintenance;
using LSFE.Infrastructure.Entities.Planning;
using LSFE.Infrastructure.Entities.TimeKeeping;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LSFE.Domain.Services
{
    public class UnitOfWork : IUnitOfWork
    {
        private readonly LSFEDbContext _context;
        public IErrorLogger ErrorLogger { get; }
        public IPlanningRepo Planning { get; }
        public IDoctorRepo Doctors { get; }
        public IAttendanceRepo Attendances {get; }
        public IMaintenanceRepo<Areas> Areas { get; }
        public IMaintenanceRepo<Districts> Districts { get; }
        public IMaintenanceRepo<Divisions> Divisions { get; }
        public IMaintenanceRepo<Territories> Territories { get; }
        public IMaintenanceRepo<Institutions> Institutions { get; }
        public IMaintenanceRepo<InstitutionCategory> InstitutionCategories { get; }
        public IMaintenanceRepo<Products> Products { get; }
        public IMaintenanceRepo<Specialization> Specializations { get; }
        public IMaintenanceRepo<Inventory> Inventory { get; }
        public IMaintenanceRepo<InventoryTransaction> InventoryTransactions { get; }
        public IMaintenanceRepo<ProductTransaction> ProductTransactions { get; }
        public IMaintenanceRepo<MRRawPlan> MRRawPlans { get; }
        public IMaintenanceRepo<CatchUpCall> CatchUpCalls { get; }
        public IMaintenanceRepo<MRPlanDetail> MRPlanDetails { get; }
        public IMaintenanceRepo<MRPlanHeader> MRPlanHeaders { get; }
        public IMaintenanceRepo<UserDevice> UserDevices { get; }
        public IReportsRepo Reports { get; }
        public UnitOfWork(LSFEDbContext context)
        {
            _context = context;
            ErrorLogger = new ErrorLogger(_context);
            Doctors = new DoctorRepo(_context);
            Planning = new PlanningRepo(_context);
            Reports = new ReportsRepo(_context);
            Attendances = new AttendanceRepo(_context);
            Areas = new MaintenanceRepo<Areas>(_context);
            Districts = new MaintenanceRepo<Districts>(_context);
            Divisions = new MaintenanceRepo<Divisions>(_context);
            Territories = new MaintenanceRepo<Territories>(_context);
            Institutions = new MaintenanceRepo<Institutions>(_context);
            InstitutionCategories = new MaintenanceRepo<InstitutionCategory>(_context);
            Products = new MaintenanceRepo<Products>(_context);
            Specializations = new MaintenanceRepo<Specialization>(_context);
            Inventory = new MaintenanceRepo<Inventory>(_context);
            InventoryTransactions = new MaintenanceRepo<InventoryTransaction>(_context);
            ProductTransactions = new MaintenanceRepo<ProductTransaction>(_context);
            MRRawPlans= new MaintenanceRepo<MRRawPlan>(_context);
            CatchUpCalls = new MaintenanceRepo<CatchUpCall>(_context);
            MRPlanDetails = new MaintenanceRepo<MRPlanDetail>(_context);
            MRPlanHeaders = new MaintenanceRepo<MRPlanHeader>(_context);
            UserDevices = new MaintenanceRepo<UserDevice>(_context);

        }

        public async Task<int> SaveChangesAsync()
        {
            return await _context.SaveChangesAsync();
        }
        public void Dispose()
        {
            _context.Dispose();
        }
    }
}