public void Use(string name)
        {
            Current = DatabaseContexts.Find(candidate => candidate.Name.Equals(name, StringComparison.OrdinalIgnoreCase));

            if (Current == null)
            {
                throw new Exception(string.Format(DataResources.DatabaseContextNameNotFoundException, name));
            }
        }
        public void Add(IDatabaseContext context)
        {
            if (Find(context) != null)
            {
                throw new Exception(string.Format(DataResources.DuplicateDatabaseContextKeyException, context.Key));
            }

            DatabaseContexts.Add(context);
        }
        public IDatabaseContext Get(string connectionString)
        {
            var result = DatabaseContexts.Find(candidate => candidate.Connection.ConnectionString.Equals(connectionString, StringComparison.OrdinalIgnoreCase));

            if (result == null)
            {
                throw new Exception(string.Format(DataResources.DatabaseContextConnectionStringNotFoundException, DbConnectionExtensions.SecuredConnectionString(connectionString)));
            }

            return(result);
        }
        public void Use(IDatabaseContext context)
        {
            Guard.AgainstNull(context, "context");

            Current = DatabaseContexts.Find(candidate => candidate.Key.Equals(context.Key));

            if (Current == null)
            {
                throw new Exception(string.Format(DataResources.DatabaseContextKeyNotFoundException, context.Key));
            }
        }
Ejemplo n.º 5
0
        public static void LogoutStateSave(string user_id)
        {
            DatabaseContexts db = new DatabaseContexts();
            AuthHistory      ah = db.auth_history.Where(s => s.user_id == user_id && s.login_date.Day == DateTime.Now.Day && s.login_date.Month == s.login_date.Month && s.login_date.Year == DateTime.Now.Year).FirstOrDefault();

            if (ah != null)
            {
                ah.logout_date = DateTime.Now;
                db.SaveChanges();
            }
        }
Ejemplo n.º 6
0
        public AccountController()
        {
            DatabaseContexts db = new DatabaseContexts();

            UserStore <ApplicationUser> userStore = new UserStore <ApplicationUser>(db);

            userManager = new UserManager <ApplicationUser>(userStore);

            RoleStore <ApplicationRole> roleStore = new RoleStore <ApplicationRole>(db);

            roleManager = new RoleManager <ApplicationRole>(roleStore);
        }
        public void Remove(IDatabaseContext context)
        {
            var candidate = Find(context);

            if (candidate == null)
            {
                return;
            }

            if (Current != null && candidate.Key.Equals(Current.Key))
            {
                Current = null;
            }

            DatabaseContexts.Remove(candidate);
        }
Ejemplo n.º 8
0
        protected override void Seed(Context.DatabaseContexts context)
        {
            DatabaseContexts            db        = new DatabaseContexts();
            UserStore <ApplicationUser> userStore = new UserStore <ApplicationUser>(db);

            userManager = new UserManager <ApplicationUser>(userStore);


            //Add roles
            RoleStore <ApplicationRole>   roleStore   = new RoleStore <ApplicationRole>(db);
            RoleManager <ApplicationRole> roleManager = new RoleManager <ApplicationRole>(roleStore);

            if (!roleManager.RoleExists("Admin"))
            {
                ApplicationRole adminRole = new ApplicationRole("Admin", "Sistem yöneticisi");
                roleManager.Create(adminRole);
            }
            if (!roleManager.RoleExists("User"))
            {
                ApplicationRole userRole = new ApplicationRole("User", "Sistem kullanıcısı");
                roleManager.Create(userRole);
            }
            if (!roleManager.RoleExists("Logistics User"))
            {
                ApplicationRole userRole = new ApplicationRole("Logistics User", "Sistem kullanıcısı, Ürün lojistik yetkisi");
                roleManager.Create(userRole);
            }


            //ApplicationUser user = new ApplicationUser();
            //user.Name = "Ad";
            //user.Surname = "Soyad";
            //user.Email = "*****@*****.**";
            //user.UserName = "******";
            //IdentityResult Iresult = userManager.Create(user, "password");
            //userManager.AddToRole(user.Id, "Admin");
        }
Ejemplo n.º 9
0
 public FeatureFlagUsersController(IDatabaseContexts context)
 {
     _context = (DatabaseContexts)context;
 }
Ejemplo n.º 10
0
 public CreateModel(DatabaseContexts context)
 {
     _context = context;
 }
 private IDatabaseContext Find(IDatabaseContext context)
 {
     return(DatabaseContexts.Find(candidate => candidate.Key.Equals(context.Key)));
 }
 public bool Contains(string connectionString)
 {
     return(DatabaseContexts.Find(candidate => candidate.Connection.ConnectionString.Equals(connectionString, StringComparison.OrdinalIgnoreCase)) != null);
 }