Esempio n. 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( );
                    }
                }
            }
        }
Esempio n. 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( );
                    }
                }
            }
        }
        public ActionResult Hire( )
        {
            using (IContextData _ContextHire = new ContextDataNH( ))
            {
                IList<Vacancy> listaVagas = null;
                listaVagas = _ContextHire.GetAll<Vacancy>( )
                             .Where(x => x.RegistrationDeadline.Day == DateTime.Now.Day - 1 && x.RegistrationDeadline.Month == DateTime.Now.Month || x.RegistrationDeadline.Month == DateTime.Now.Month - 1 && x.RegistrationDeadline.Year == DateTime.Now.Year && x.Status.Code == 2)
                             .ToList( );
                if (listaVagas.Count( ) > 0)
                {
                    IList<JobCandidate> listJobs = null;
                    IList<Profile> listProfile = null;
                    string EmailsProfile = null;
                    IList<Profile> listProfileCopy = new List<Profile>( );
                    foreach (var itemListaVagas in listaVagas)
                    {
                        listJobs = _ContextHire.GetAll<JobCandidate>( )
                                   .Where(x => x.JobCandidato.Id == itemListaVagas.Id).ToList( );
                        if (listJobs.Count( ) > 0)
                        {

                            string Description = itemListaVagas.KeyWords.ToLower( );

                            string[] Letras = Description.Split(new char[] { ',' });

                            foreach (var itemJobs in listJobs)
                            {
                                listProfile = _ContextHire.GetAll<Profile>( )
                                              .Where(x => x.IdUser == itemJobs.UserJobs.Id)
                                              .ToList( );
                                //talvez precise verificar se não tem nenhum usuário inscrito

                                foreach (var itemProfile in listProfile)
                                {
                                    string IntersectIndividual = (from c in _ContextHire.GetAll<Profile>( )
                                                                  .Where(x => x.Code == itemProfile.Code)
                                                                  select c.KeyWords.ToLower( )).First( );

                                    if (IntersectIndividual != null)
                                    {
                                        string[] PalavrasInteresseIndividual = IntersectIndividual.Split(new char[] { ',' });
                                        int encontrado = 0;
                                        foreach (var palavrasDaDescricao in Letras)
                                        {

                                            foreach (var itemInteresse in PalavrasInteresseIndividual)
                                            {

                                                var list = (from c in listProfile
                                                            where palavrasDaDescricao.ToLower( ).Contains(itemInteresse.ToLower( ))
                                                            select c).ToList( );

                                                if (list.Count( ) > 0)
                                                {
                                                    encontrado++;
                                                    var listScoreUser = _ContextHire.GetAll<Score>( )
                                                                        .Where(x => x.ScoreProfileUser.Code == itemProfile.Code && x.ScoreVacancy.Id == itemListaVagas.Id)
                                                                        .ToList( );
                                                    if (listScoreUser.Count( ) >= 1)
                                                    {
                                                        Score ScoreUpdate = _ContextHire.GetAll<Score>( )
                                                                          .Where(x => x.ScoreProfileUser.Code == itemProfile.Code && x.ScoreVacancy.Id == itemListaVagas.Id)
                                                                        .First( );
                                                        ScoreUpdate.ScoreProfileUser = _ContextHire.Get<Profile>(itemProfile.Code);
                                                        ScoreUpdate.ScoreVacancy = _ContextHire.Get<Vacancy>(itemListaVagas.Id);
                                                        ScoreUpdate.ScoreUser = encontrado;
                                                        _ContextHire.SaveChanges( );

                                                    }
                                                    else
                                                    {
                                                        Score ScoreUser = new Score( );
                                                        ScoreUser.ScoreProfileUser = _ContextHire.Get<Profile>(itemProfile.Code);
                                                        ScoreUser.ScoreVacancy = _ContextHire.Get<Vacancy>(itemListaVagas.Id);
                                                        ScoreUser.ScoreUser = encontrado;
                                                        _ContextHire.Add<Score>(ScoreUser);
                                                        _ContextHire.SaveChanges( );

                                                    }

                                                    Profile ProfileSendMail = _ContextHire.Get<Profile>(itemProfile.Code);
                                                    listProfileCopy.Add(ProfileSendMail);

                                                }

                                            }
                                        }
                                    }
                                      //aqui estudante antes

                                    //estava aqui

                                }

                                //agora envio de estudante
                                foreach (var itemEmail in listProfileCopy.Distinct( ))
                                {
                                    WebMail.Send(itemEmail.EmailAddress, "Parabéns você esta concorrendo a vaga de " + itemListaVagas.ProfileVacancy.Myprofile, "Aguarde o contato da empresa " + itemListaVagas.CompanyName.Name);

                                }

                            }

                        }

                        var listScoreVacancy = (from sc in _ContextHire.GetAll<Score>( )
                                                      .Where(x => x.ScoreVacancy.Id == itemListaVagas.Id )
                                                join pf in _ContextHire.GetAll<Profile>( )
                                                on sc.ScoreProfileUser.Code equals pf.Code
                                                orderby sc.ScoreUser descending
                                                select new { Nome = pf.FirstName, URLPública = pf.PublicUrl, Email = pf.EmailAddress + "</br>" });
                        if (listScoreVacancy.Count() > 0)
                        {

                        EmailsProfile = String.Join(",", listScoreVacancy);

                        string BodyMessageCompany = itemListaVagas.CompanyName.Name + "," + " \n" +
                               "Segue abaixo a relação dos candidatos que de acordo com seu perfil estão aptos a vaga descrita:" + "(" + itemListaVagas.ProfileVacancy.Myprofile + ")" + "\n" +
                              "classificada em ordem decrescente em relação aos que melhores se enquadram na vaga, caso queira analisar o perfil público" + "\n" +
                              "do candidato clique no link correspondente. " + EmailsProfile;
                        WebMail.Send(itemListaVagas.CompanyName.Email, "Lista de Classificados pelo IdezJobs ", BodyMessageCompany);
                        }
                    }

                }

            }
            return View( );
        }