Beispiel #1
0
        public static ApplicationUserManager Create(IdentityFactoryOptions <ApplicationUserManager> options, IOwinContext context)
        {
            ApiDbcontext           db          = context.Get <ApiDbcontext>();
            ApplicationUserManager userManager = new ApplicationUserManager(new UserStore <Account>(db));

            userManager.PasswordValidator = new ApplicationPasswordValidator
            {
                RequiredLength          = 6,
                RequireNonLetterOrDigit = false,
                RequireDigit            = false,
                RequireLowercase        = true,
                RequireUppercase        = true
            };

            userManager.UserValidator = new UserValidator <Account>(userManager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail             = true
            };

            //userManager.EmailService = new EmailService();

            var dataProtectionProvider = options.DataProtectionProvider;

            if (dataProtectionProvider != null)
            {
                userManager.UserTokenProvider = new DataProtectorTokenProvider <Account>(dataProtectionProvider.Create("ASP.NET Identity"))
                {
                    //Code for email confirmation and reset password life time
                    TokenLifespan = TimeSpan.FromHours(6)
                };
            }
            return(userManager);
        }
Beispiel #2
0
 public TodoController(ApiDbcontext dbContext)
 {
     _dbContext = dbContext;
     if (!_dbContext.TodoItems.Any())
     {
         _dbContext.TodoItems.Add(new TodoItem {
             Name = "Item1"
         });
         _dbContext.SaveChanges();
     }
 }
        // Load config data from EF DB.
        public override void Load()
        {
            var builder = new DbContextOptionsBuilder <ApiDbcontext>();

            OptionsAction(builder);

            using (var dbContext = new ApiDbcontext(builder.Options))
            {
                dbContext.Database.EnsureCreated();
                Data = !dbContext.ConfigurationValues.Any()
                    ? CreateAndSaveDefaultValues(dbContext)
                    : dbContext.ConfigurationValues.ToDictionary(c => c.Id, c => c.Value);
            }
        }
        private static IDictionary <string, string> CreateAndSaveDefaultValues(
            ApiDbcontext dbContext)
        {
            var configValues = new Dictionary <string, string>
            {
                { "key1", "value_from_ef_1" },
                { "key2", "value_from_ef_2" }
            };

            dbContext.ConfigurationValues.AddRange(configValues
                                                   .Select(kvp => new ConfigurationValue {
                Id = kvp.Key, Value = kvp.Value
            })
                                                   .ToArray());
            dbContext.SaveChanges();
            return(configValues);
        }
 public GiaoVienController()
 {
     this.db = new ApiDbcontext();
 }
Beispiel #6
0
 public FornecedorController(ApiDbcontext context)
 {
     _context = context;
 }
 public SinhVienController()
 {
     this.db = new ApiDbcontext();
 }
Beispiel #8
0
 public LopController()
 {
     this.db = new ApiDbcontext();
 }