Example #1
0
        protected void Application_Start()
        {
            using (SaglikContext ent = new SaglikContext())
            {
                ent.Database.CreateIfNotExists();
            }
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            //Role Tanımlama Adımları
            SaglikContext db = new SaglikContext();
            RoleStore <AplicationRole>   roleStore   = new RoleStore <AplicationRole>(db);
            RoleManager <AplicationRole> roleManager = new RoleManager <AplicationRole>(roleStore);

            if (!roleManager.RoleExists("Admin"))
            {
                AplicationRole adminRole = new AplicationRole("Admin", "Sistem Yöneticisi");
                roleManager.Create(adminRole);
            }
            if (!roleManager.RoleExists("User"))
            {
                AplicationRole UserRole = new AplicationRole("User", "Sistem Kullanıcısı");
                roleManager.Create(UserRole);
            }
        }
        private DbSet <T> _dbSet;           //tablo

        public Repository(SaglikContext context)
        {
            if (context != null)
            {
                _blogContext = context;
                _dbSet       = _blogContext.Set <T>();
            }
        }
        public AccountController()
        {
            SaglikContext ent = new SaglikContext();
            UserStore <ApplicationUser> UserStore = new UserStore <ApplicationUser>(ent);

            userManager = new UserManager <ApplicationUser>(UserStore);
            RoleStore <AplicationRole> roleStore = new RoleStore <AplicationRole>(ent);

            roleManager = new RoleManager <AplicationRole>(roleStore);
        }
 protected void Application_Start()
 {
     using (SaglikContext ent = new SaglikContext())
     {
         ent.Database.CreateIfNotExists();
     }
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }