void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // add admin user
            Models.ApplicationDbContext context = new ApplicationDbContext();
            IdentityResult IdRoleResult;
            IdentityResult IdUserResult;

            // Create a RoleStore object by using the ApplicationDbContext object.
            // The RoleStore is only allowed to contain IdentityRole objects.
            var roleStore = new RoleStore <IdentityRole>(context);

            // Create a RoleManager object that is only allowed to contain IdentityRole objects.
            // When creating the RoleManager object, you pass in (as a parameter) a new RoleStore object.
            var roleMgr = new RoleManager <IdentityRole>(roleStore);

            // Then, create the role if it doesn't already exist.
            if (!roleMgr.RoleExists("admin"))
            {
                IdRoleResult = roleMgr.Create(new IdentityRole {
                    Name = "admin"
                });
            }

            // Create a UserManager object based on the UserStore object and the ApplicationDbContext
            // object. Note that you can create new objects and use them as parameters in
            // a single line of code, rather than using multiple lines of code, as you did
            // for the RoleManager object.
            var userMgr = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
            var appUser = new ApplicationUser
            {
                UserName = "******",
                Email    = "*****@*****.**",
                Type     = "Admin",
                Name     = "Admin"
            };

            IdUserResult = userMgr.Create(appUser, "Pa$$word1");

            // If the new "admin" user was successfully created,
            // add the "admin" user to the "admin" role.
            if (!userMgr.IsInRole(userMgr.FindByEmail(appUser.Email).Id, "admin"))
            {
                IdUserResult = userMgr.AddToRole(userMgr.FindByEmail(appUser.Email).Id, "admin");
            }
            // Create the roles and users.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole("*****@*****.**", "Pa$$word1", "admin", "Admin", "Admin");
            roleActions.AddUserAndRole("*****@*****.**", "Pa$$word1", "user", "Mary Riley", "Hygienist");
            roleActions.AddUserAndRole("*****@*****.**", "Pa$$word1", "user", "Dan Johnson", "Doctor");
            roleActions.AddUserAndRole("*****@*****.**", "Pa$$word1", "patient", "Ryan Jessen", "Patient");
        }
Exemple #2
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //Database.SetInitializer(new ArticleDatabaseInitializer());

            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole("Admin23", "*****@*****.**", "Pa$$word1", "roleAdmin");
            roleActions.AddUserAndRole("Editor23", "*****@*****.**", "Pa$$word1", "roleEditor");
            roleActions.AddUserAndRole("User23", "*****@*****.**", "Pa$$word1", "roleRegistered");
        }
Exemple #3
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize the product database.
            //Database.SetInitializer(new ProductDatabaseInitializer());

            // Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
            CssManager.CssResourceMapping.AddDefinition("juice-ui", new CssResourceDefinition
            {
                Path      = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/ui-lightness/jquery-ui.css",
                DebugPath = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/ui-lightness/jquery-ui.css"
            });

            MetaModel DefaultModel = new MetaModel();

            DefaultModel.RegisterContext(new Microsoft.AspNet.DynamicData.ModelProviders.EFDataModelProvider(
                                             () => new ProductContext()),
                                         new ContextConfiguration {
                ScaffoldAllTables = false
            });
        }
Exemple #4
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            //RouteConfig.RegisterRoutes(RouteTable.Routes);
            //BundleConfig.RegisterBundles(BundleTable.Bundles);
            //FacebookConfig.Register(GlobalFacebookConfiguration.Configuration);
            FacebookConfig.Register(GlobalFacebookConfiguration.Configuration);
            //GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);


            // Initialize the product database.
            // Database.SetInitializer(new ProductDatabaseInitializer());

            //Database.SetInitializer<ProductContext>(
            //										new DropCreateDatabaseAlways<ProductContext>());

            // Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();

            // Add Routes.
            RegisterCustomRoutes(RouteTable.Routes);
        }
Exemple #5
0
        protected void Application_Start(object sender, EventArgs e)
        {
            Database.SetInitializer(new BazaArtikalaInit());

            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
Exemple #7
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            Database.SetInitializer(new ProductDatabaseInitializer());

            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //Initialize menu database
            Database.SetInitializer(new ProductDatabaseInitializer());

            RoleActions roleActions = new RoleActions();
            roleActions.AddUserAndRole();
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Código que é executado na inicialização do aplicativo
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Cria regra customizada e usuário
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
        void Application_Start(object sender, EventArgs e)
        {
            // 在应用程序启动时运行的代码
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            // Initialize the product database.
            Database.SetInitializer(new ProductDatabaseInitializer());

            // Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
Exemple #12
0
        void Application_Start(object sender, EventArgs e)
        {
            var config = GlobalConfiguration.Configuration;

            config.EnableCors();
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            //// Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
Exemple #13
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            // Initialize the product database.
            Database.SetInitializer(new DbInitializer());
            //create custom role and user
            RoleActions roleActioons = new RoleActions();

            roleActioons.AddUserAndRole();
            // Add Routes.
            RegisterCustomRoutes(RouteTable.Routes);
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize database
            Database.SetInitializer(new ReportsDatabaseInitializer());

            // Create roles and admin user
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize database.
            Database.SetInitializer(new ProductDatabaseInitializer());

            // Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
        }
Exemple #16
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            // Initialize the product database.
            Database.SetInitializer(new ProductDatabaseInitializer());
            // Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();
            // Add Routes.
            RegisterCustomRoutes(RouteTable.Routes);
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;//
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Database.SetInitializer(new CatalogObjectInitializer());

            RoleActions ra = new RoleActions();

            ra.AddUserAndRole();

            RouteActions rta = new Logic.RouteActions();

            rta.RegisterCustomRoutes(RouteTable.Routes);
        }
Exemple #18
0
        void Application_Start(object sender, EventArgs e)
        {
            // Код, выполняемый при запуске приложения
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize the product database.
            Database.SetInitializer(new ProductDatabaseInitializer());

            // Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();

            // Add Routes.
            RegisterCustomRoutes(RouteTable.Routes);
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize the product database.
            Database.SetInitializer(new ProductDatabaseInitializer());

            //власний користувач та роль
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();

            //добавляєм шляхи
            RouteActions.RegisterCustomRoutes(RouteTable.Routes);
        }
Exemple #20
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //init product related database
            Database.SetInitializer(new ProductDatabaseInitializer());

            //create custome role: canEdit
            //  user: [email protected]/pa$$word1
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();

            RoutesActions.RegisterCustomRoutes(RouteTable.Routes);
        }
Exemple #21
0
        //Kada se pokrene aplikacija ona poziva Application_Start upravljača događaja
        void Application_Start(object sender, EventArgs e)
        {
            // Kod koji radi na pokretanju aplikacije
            //Poziv metode RegisterRoutes koristeći objekat RouteConfig na početku upravljača događaja Application_Start je poziv
            //napravljen da primeni podrazumevano rutiranje.
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Inicijalizacija baze podataka proizvoda.
            Database.SetInitializer(new ProductDatabaseInitializer());

            // Kreiranje custom role i korisnika.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();

            // Dodavanje Routes (rute)
            RegisterCustomRoutes(RouteTable.Routes);
        }
Exemple #22
0
        void Application_Start(object sender, EventArgs e)
        {
            // Start with defaults
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize the product database
            Database.SetInitializer(new ProductDatabaseInitializer());

            // Create custom role and user
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();

            // Add custom routes
            RouteActions routeActions = new RouteActions();

            routeActions.RegisterCustomRoutes(RouteTable.Routes);
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initializa the product datbase.
            Database.SetInitializer(new ProductDatabaseInitializer());

            System.Threading.Thread.CurrentThread.CurrentCulture =
                new System.Globalization.CultureInfo("en-US", true);

            // Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();

            // Add Routes.
            RouteActions.RegisterCustomRoutes(RouteTable.Routes);
        }
Exemple #24
0
        void Application_Start(object sender, EventArgs e)
        {
            // Setup the Service Configuration
            ServerConfig.RegisterConfig("development");

            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize the product database.
            Database.SetInitializer(new ProductDatabaseInitializer());

            // Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();

            // Add Routes.
            RegisterCustomRoutes(RouteTable.Routes);
        }
Exemple #25
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize the product database.
            Database.SetInitializer <ProductContext>(new ProductDatabaseInitializer());

            using (var context = new ProductContext())
            {
                context.Database.Initialize(true);
            }

            // Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();

            // Add Routes.
            RegisterCustomRoutes(RouteTable.Routes);
        }
Exemple #26
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Create the custom role and user.
            RoleActions roleActions = new RoleActions();

            roleActions.AddUserAndRole();

            //RouteTable.Routes.MapHttpRoute(
            //    name: "WithActionApi",
            //    routeTemplate: "api/{controller}/{action}/{id}"
            // );

            RouteTable.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = System.Web.Http.RouteParameter.Optional }
                );
        }