示例#1
0
        protected void Application_Start( )
        {
            AreaRegistration.RegisterAllAreas( );

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            if (System.Web.Security.Roles.GetAllRoles( ).Length == 0)
            {
                using (IContextData ctx = new ContextDataNH( ))
                {
                    ctx.setup( );
                    System.Web.Security.Roles.CreateRole("Administrador");

                    MembershipCreateStatus status;
                    Membership.CreateUser("IdezJobs", "JobsIdezypa", "*****@*****.**", null, null, true, out status);
                    if (status == MembershipCreateStatus.Success)
                    {
                        Administrator Administ = new Administrator( );
                        Administ.Name = "IdezJobs";
                        Administ.Password = "******";
                        Administ.Email = "*****@*****.**";
                        Administ.Type = "Administrator";

                        ctx.Add<Administrator>(Administ);
                        ctx.SaveChanges( );

                        Roles.AddUserToRole("IdezJobs", "Administrador");
                        ctx.Dispose( );
                    }
                }
            }
        }
示例#2
0
        protected void Application_Start( )
        {
            AreaRegistration.RegisterAllAreas( );

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            if (System.Web.Security.Roles.GetAllRoles( ).Length == 0)
            {
                using (IContextData ctx = new ContextDataNH( ))
                {
                    ctx.setup( );
                    System.Web.Security.Roles.CreateRole("Administrador");
                    System.Web.Security.Roles.CreateRole("Company");
                    System.Web.Security.Roles.CreateRole("Student");

                    MembershipCreateStatus status;
                    Membership.CreateUser("IdezJobs", "JobsIdezypa", "*****@*****.**", null, null, true, out status);
                    Membership.CreateUser("Estudante", "senha123", "*****@*****.**", null, null, true, out status);
                    Membership.CreateUser("Empresa", "empresa123", "*****@*****.**", null, null, true, out status);
                    if (status == MembershipCreateStatus.Success)
                    {
                        Administrator Administ = new Administrator( );
                        Administ.Name = "IdezJobs";
                        Administ.Password = "******";
                        Administ.Email = "*****@*****.**";
                        Administ.Type = "Administrator";

                        ctx.Add<Administrator>(Administ);
                        ctx.SaveChanges( );

                        User userEstudante = new User( );
                        userEstudante.DateRegister = DateTime.Now;
                        userEstudante.Email = "*****@*****.**";
                        userEstudante.Name = "Estudante";
                        userEstudante.Token = "Token";
                        userEstudante.Type = "Estudante";

                        ctx.Add<User>(userEstudante);
                        ctx.SaveChanges( );

                        User userEmpresa = new User( );
                        userEmpresa.DateRegister = DateTime.Now;
                        userEmpresa.Email = "*****@*****.**";
                        userEmpresa.Name = "Empresa";
                        userEmpresa.Token = "Token Empresa";
                        userEmpresa.Type = "Company";

                        ctx.Add<User>(userEmpresa);
                        ctx.SaveChanges( );

                        Status s1 = new Status( );
                        s1.Description = "Aberto";
                        ctx.Add<Status>(s1);
                        ctx.SaveChanges( );

                        Status s2 = new Status( );
                        s2.Description = "Fechado";
                        ctx.Add<Status>(s2);
                        ctx.SaveChanges( );

                        Roles.AddUserToRole("IdezJobs", "Administrador");
                        Roles.AddUserToRole("Estudante", "Student");
                        Roles.AddUserToRole("Empresa", "Company");

                        ctx.Dispose( );
                    }
                }
            }
        }