using Bp.Sync.BackEnd.Factories;
using Bp.Sync.BackEnd.Infrastructure.Repositories;
using Bp.Sync.BackEnd.Infrastructure.Repositories.DailyInventoryDiarys;
using Bp.Sync.BackEnd.Infrastructure.Repositories.Davs;
using Bp.Sync.BackEnd.Infrastructure.Repositories.FcBusinesses;
using Bp.Sync.BackEnd.Infrastructure.Repositories.FcCustomers;
using Bp.Sync.BackEnd.Infrastructure.Repositories.Systems;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Nest;

namespace Bp.Sync.BackEnd.Infrastructure
{
    public class DependencyRegister
    {
        public static void Register(IServiceCollection services)
        {
            services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
            // Register the client provider as a singleton
            services.AddTransient(typeof(ElasticClientProvider));

            //INDEX
            services.AddSingleton<ElasticClient>();

            services.AddTransient<ISyncFactory, SyncFactory>();
            services.AddTransient<IUpdateFactory, UpdateFactory>();

            //Repository

            //inventory
            services.AddTransient<ITransactionRepository, TransactionRepository>();
            services.AddTransient<IBillRepository, BillRepository>();
            services.AddTransient<IOutboundBillRepository, OutboundBillRepository>();
            services.AddTransient<IInboundBillRepository, InboundBillRepository>();
            services.AddTransient<IInventoryBillRepository, InventoryBillRepository>();
            services.AddTransient<IInvoiceRepository, InvoiceRepository>();
            services.AddTransient<IProductRepository, ProductRepository>();
            services.AddTransient<IProductInventoryRepository, ProductInventoryRepository>();
            services.AddTransient<IProductInvoiceRepository, ProductInvoiceRepository>();
            services.AddTransient<IOrderRepository, OrderRepository>();
            services.AddTransient<IProductOrderRepository, ProductOrderRepository>();
            services.AddTransient<IRetailBillRepository, RetailBillRepository>();
            services.AddTransient<IBranchRepository, BranchRepository>();
            services.AddTransient<IUnitRepository, UnitRepository>();
            services.AddTransient<IProductUnitRepository, ProductUnitRepository>();
            services.AddTransient<ICustomerRepository, CustomerRepository>();
            services.AddTransient<ISupplierRepository, SupplierRepository>();
            services.AddTransient<IBatchRepository, BatchRepository>();
            services.AddTransient<IUserDistrictRepository, UserDistrictRepository>();
            services.AddTransient<ICategoryRepository, CategoryRepository>();
            services.AddTransient<IProductGroupRepository, ProductGroupRepository>();
            services.AddTransient<IProductTypeRepository, ProductTypeRepository>();
            services.AddTransient<IProductBillRepository, ProductBillRepository>();
            services.AddTransient<IDebtRepository, DebtRepository>();
            services.AddTransient<IGeneralLedgerRepository, GeneralLedgerRepository>();
            services.AddTransient<IAccountRepository, AccountRepository>();
            services.AddTransient<IBaseConfigurationRepository, BaseConfigurationRepository>();
            services.AddTransient<IContractDiscountLevelRepository, ContractDiscountLevelRepository>();
            services.AddTransient<IDiscountBranchDetailConfigRepository, DiscountBranchDetailConfigRepository>();
            services.AddTransient<IWholesalePriceListRepository, WholesalePriceListRepository>();
            services.AddTransient<IReasonRepository, ReasonRepository>();
            services.AddTransient<IPromotionRepository, PromotionRepository>();
            services.AddTransient<IPromotionProductRepository, PromotionProductRepository>();

            //fc
            services.AddTransient<IRetailStatisticRepository, RetailStatisticRepository>();
            services.AddTransient<IInboundStatisticRepository, InboundStatisticRepository>();
            services.AddTransient<IOutboundStatisticRepository, OutboundStatisticRepository>();
            services.AddTransient<IFcCustomerRepository, FcCustomerRepository>();
            services.AddTransient<IFcInboundBillRepository, FcInboundBillRepository>();
            services.AddTransient<IFcOutboundBillRepository, FcOutboundBillRepository>();
            services.AddTransient<IFcReceiptBillRepository, FcReceiptBillRepository>();
            services.AddTransient<IFcProductStorageRepository, FcProductStorageRepository>();
            services.AddTransient<IFcUnitExchangeRepository, FcUnitExchangeRepository>();
            services.AddTransient<IFcProductShipmentRepository, FcProductShipmentRepository>();
            services.AddTransient<IFcProductSummaryRepository, FcProductSummaryRepository>();

            services.AddTransient<IFcProductInboundRepository, FcProductInboundRepository>();
            services.AddTransient<IFcProductOutboundRepository, FcProductOutboundRepository>();

            //daily task
            services.AddTransient<IHistoryElasticRepository, HistoryElasticRepository>();
            services.AddTransient<IDailyTaskFactory, DailyTaskFactory>();
            services.AddTransient<IDailyInventoryDiaryRepository, DailyInventoryDiaryRepository>();

            //dav
            services.AddTransient<ISyncDavTaskFactory, SyncDavTaskFactory>();
            services.AddTransient<IProductStorageDavRepository, ProductStorageDavRepository>();
        }
    }
}