// This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            // Autofac Container
            var builder = new ContainerBuilder();

            // DbContext
            DbContextConfig.Register(services, Configuration);

            // Autofac
            AutofacConfig.Register(builder);

            // AutoMapper
            AutoMapperConfig.Register(builder);

            // Identity
            services.AddDbContext <AppIdentityDbContext>(options =>
                                                         options.UseSqlServer(
                                                             Configuration.GetConnectionString("DefaultConnection")));
            services.AddDefaultIdentity <IdentityUser>()
            .AddEntityFrameworkStores <AppIdentityDbContext>();

            // MVC
            services.AddMemoryCache();
            services.AddDistributedMemoryCache();
            services.AddSession();
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddMvc(options =>
            {
                //options.Filters.Add(typeof(GlobalExceptionFilter));
                //options.ModelBinderProviders.Insert(0, new DateTimeUtcModelBinderProvider());
            })
            .AddJsonOptions(x =>
            {
                x.SerializerSettings.NullValueHandling     = NullValueHandling.Ignore;
                x.SerializerSettings.DateTimeZoneHandling  = DateTimeZoneHandling.Utc;
                x.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            // Build Autofac Service Provider
            builder.Populate(services);
            var container = builder.Build();

            _serviceProvider = new AutofacServiceProvider(container);
            return(_serviceProvider);
        }