using Autofac;
using Nop.Core.Configuration;
using Nop.Core.Infrastructure;
using Nop.Core.Infrastructure.DependencyManagement;
using Nop.Services.Blogs;
using Nop.Services.Catalog;
using Nop.Services.Customers;
using Nop.Services.Security;
using Nop.Services.TobpicSideMenuB2C;
using Nop.Services.Topics;
using Nop.Services.TopicSideMenuService;
using Nop.Services.Vendors;
using Nop.Web.Areas.Admin.Controllers;
using Nop.Web.Areas.Admin.Factories;
using Nop.Web.Factories;
using Nop.Web.Framework.Factories;
using Nop.Web.Infrastructure.Installation;

namespace Nop.Web.Infrastructure
{
    /// <summary>
    /// Dependency registrar
    /// </summary>
    public class DependencyRegistrarB2C : IDependencyRegistrar
    {
        /// <summary>
        /// Register services and interfaces
        /// </summary>
        /// <param name="builder">Container builder</param>
        /// <param name="typeFinder">Type finder</param>
        /// <param name="config">Config</param>
        public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
        {
            //installation localization service

            builder.RegisterType<HomeB2CController>().As<HomeController>().InstancePerLifetimeScope();
            builder.RegisterType<CategoryB2CController>().As<CategoryController>().InstancePerLifetimeScope();
            builder.RegisterType<Controllers.CatalogB2CController>().As<Controllers.CatalogController>().InstancePerLifetimeScope();
            builder.RegisterType<BlogB2CController>().As<BlogController>().InstancePerLifetimeScope();
            builder.RegisterType<CommonB2CController>().As<CommonController>().InstancePerLifetimeScope();
            builder.RegisterType<OrderB2CController>().As<OrderController>().InstancePerLifetimeScope();
            builder.RegisterType<SecurityB2CController>().As<SecurityController>().InstancePerLifetimeScope();
            builder.RegisterType<CustomerB2CService>().As<ICustomerB2CService>().InstancePerLifetimeScope();
            builder.RegisterType<CustomerB2CModelFactory>().As<ICustomerB2CModelFactory>().InstancePerLifetimeScope();
            builder.RegisterType<CustomerB2CController>().As<CustomerController>().InstancePerLifetimeScope();
            builder.RegisterType<AclSupportedB2CModelFactory>().As<IAclSupportedB2CModelFactory>().InstancePerLifetimeScope();
            builder.RegisterType<ProductB2CController>().As<ProductController>().InstancePerLifetimeScope();
            builder.RegisterType<AclB2CService>().As<IAclB2CService>().InstancePerLifetimeScope();
            builder.RegisterType<ProductB2CModelFactory>().As<IProductB2CModelFactory>().InstancePerLifetimeScope();
            builder.RegisterType<Nop.Web.Controllers.CustomerB2CController>().As<Nop.Web.Controllers.CustomerController>().InstancePerLifetimeScope();
            builder.RegisterType<CatalogModelB2CFactory>().As<ICatalogModelB2CFactory > ().InstancePerLifetimeScope();
            builder.RegisterType<Nop.Web.Controllers.ProductMtb2cController>().As<Nop.Web.Controllers.ProductController>().InstancePerLifetimeScope();
            builder.RegisterType<ProductServiceB2C>().As<IProductServiceB2C>().InstancePerLifetimeScope();
            builder.RegisterType<BlogsB2CService>().As<IBlogsB2CService>().InstancePerLifetimeScope();

            builder.RegisterType<TopicSideMenuB2CController>().InstancePerLifetimeScope();
            builder.RegisterType<TopicSideMenuB2CModelFactory>().As<ITopicSideMenuB2CModelFactory>().InstancePerLifetimeScope();
            builder.RegisterType<TopicSideMenuB2CService>().As<ITopicSideMenuB2CService>().InstancePerLifetimeScope();
            builder.RegisterType<TopicB2CController>().As<TopicController>().InstancePerLifetimeScope();
            builder.RegisterType<TopicB2CModelFactory>().As<ITopicB2CModelFactory>().InstancePerLifetimeScope();

            builder.RegisterType<TopicB2CService>().As<ITopicB2CService>().InstancePerLifetimeScope();

        }

        /// <summary>
        /// Gets order of this dependency registrar implementation
        /// </summary>
        public int Order => 2;
    }
}
