Esempio n. 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddTransient <IUserValidator <User>, CustomUserValidator>();

            services.AddTransient <IPasswordValidator <User>,
                                   CustomPasswordValidator>(serv => new CustomPasswordValidator(6));


            string connection = Configuration.GetConnectionString("DefaultConnection");

            services.AddDbContext <CatsContext>(options => options.UseSqlServer(connection));
            services.AddControllersWithViews();

            string connectionIdentity = Configuration.GetConnectionString("IdentityConnection");

            services.AddDbContext <IdentityContext>(options => options.UseSqlServer(connectionIdentity));
            services.AddControllersWithViews();

            services.AddIdentity <User, IdentityRole>().AddDefaultTokenProviders().AddEntityFrameworkStores <IdentityContext>();

            var context = services.BuildServiceProvider()
                          .GetService <CatsContext>();

            Controllers.BotTelegram bot =
                new Controllers.BotTelegram(context);
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            string connection = Configuration.GetConnectionString("DefaultConnection");

            services.AddDbContext <CatsContext>(options => options.UseSqlServer(connection));

            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlite(
                                                             Configuration.GetConnectionString("IdentityConnection")));
            services.AddDefaultIdentity <IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
            .AddEntityFrameworkStores <ApplicationDbContext>();
            services.AddControllersWithViews();
            services.AddRazorPages();
            var context = services.BuildServiceProvider()
                          .GetService <CatsContext>();

            Controllers.BotTelegram bot =
                new Controllers.BotTelegram(context);
        }