Example #1
0
 public IEnumerable <RepositoryCategoryResult> GetJobCategories()
 {
     using (var dbContext = new JobPortalDbContext())
     {
         return(dbContext.JobCategories.OrderBy(jc => jc.Id).Select((jc) => new RepositoryCategoryResult
         {
             Id = jc.Id,
             Name = jc.Name
         }).ToList());
     }
 }
Example #2
0
 public IEnumerable <RepositoryLocationResult> GetLocations()
 {
     using (var dbContext = new JobPortalDbContext())
     {
         return(dbContext.Locations.OrderBy(l => l.Id).Select((l) => new RepositoryLocationResult
         {
             Id = l.Id,
             Address = l.Address
         }).ToList());
     }
 }
Example #3
0
 public IEnumerable <RepositoryJobPostResult> GetJobPosts(RepositoryJobPostSearchInputModel searchInputModel)
 {
     using (var jobPortalDbContext = new JobPortalDbContext())
     {
         string   selectStatement = "SELECT jp.Id AS Id, jp.IsBookmarked, jp.JobPostThumbnailUrl, jp.Views, jp.CreatedAt, et.Name AS EmploymentType, jc.Name AS JobCategory, jt.Name AS Title, l.Address AS Location";
         object[] sqlParams       = null;
         string   query           = GetBaseJobPostQuery(selectStatement, searchInputModel, shouldSort: true, sqlParams: out sqlParams);
         var      result          = jobPortalDbContext.Database.SqlQuery <RepositoryJobPostResult>(query, sqlParams).ToList();
         return(result);
     }
 }
Example #4
0
 public int GetJobPostCount(RepositoryJobPostSearchInputModel searchInputModel)
 {
     using (var jobPortalDbContext = new JobPortalDbContext())
     {
         string   selectStatement = "SELECT COUNT(*)";
         object[] sqlParams       = null;
         string   query           = GetBaseJobPostQuery(selectStatement, searchInputModel, shouldSort: false, sqlParams: out sqlParams);
         var      postCount       = jobPortalDbContext.Database.SqlQuery <int>(query, sqlParams).First();
         return(postCount);
     }
 }
        public static void SeedHostDb(JobPortalDbContext context)
        {
            context.SuppressAutoSetTenantId = true;

            // Host seed
            new InitialHostDbBuilder(context).Create();

            // Default tenant seed (in host database).
            new DefaultTenantBuilder(context).Create();
            new TenantRoleAndUserBuilder(context, 1).Create();
        }
 public IEnumerable <RepositoryEmploymentTypeResult> GetEmploymentTypes()
 {
     using (var dbContext = new JobPortalDbContext())
     {
         return(dbContext.EmploymentTypes.OrderBy(et => et.Id).Select((et) => new RepositoryEmploymentTypeResult
         {
             Id = et.Id,
             Name = et.Name
         }).ToList());
     }
 }
Example #7
0
 public void SetBookmarkState(int jobPostId, bool isBookmarked)
 {
     using (var dbContext = new JobPortalDbContext())
     {
         var jobPost = new JobPost
         {
             Id           = jobPostId,
             IsBookmarked = isBookmarked
         };
         dbContext.JobPosts.Attach(jobPost);
         dbContext.Entry <JobPost>(jobPost).Property(jp => jp.IsBookmarked).IsModified = true;
         dbContext.SaveChanges();
     }
 }
Example #8
0
        static void Main(string[] args)
        {
            using (var context = new JobPortalDbContext())
            {
                // there should be 3 companies
                foreach (var company in context.Employers.ToList())
                {
                    Console.WriteLine(company.Name + " : " + company.JobOffers?.Count);
                }

                // there should be 2 users
                foreach (var user in context.Users.ToList())
                {
                    Console.WriteLine("User: "******"(" + user.Password + ")");
                    Console.WriteLine("Skills: " + string.Join(",", user.Skills));
                    Console.WriteLine("Number of applications: " + user.JobApplications.Count);
                }


                // test repository
                using (var unitOfWork = Provider.Create())
                {
                    Console.WriteLine(ApplicantRepository.Get(1).FirstName);
                }

                TestQuery().Wait();

                Mapper mapper = new Mapper(new MapperConfiguration(MappingConfiguration.ConfigureMapping));

                TestRegister(mapper).Wait();
                TestCreateOffer(mapper).Wait();
                TestCreateApplicationRegistered(mapper).Wait();
                TestCreateApplicationUnRegistered(mapper).Wait();
                TestRecommendedJobs(mapper).Wait();
            }
            Console.ReadLine();
        }
Example #9
0
 public TenantRoleAndUserBuilder(JobPortalDbContext context, int tenantId)
 {
     _context  = context;
     _tenantId = tenantId;
 }
Example #10
0
 public DefaultSettingsCreator(JobPortalDbContext context)
 {
     _context = context;
 }
 public HomeController(JobPortalDbContext context)
 {
     _context = context;
 }
Example #12
0
        private static DbContext InitializeDatabase()
        {
            var context = new JobPortalDbContext(Effort.DbConnectionFactory.CreatePersistent(TestDbConnectionString));

            context.Employers.RemoveRange(context.Employers);
            context.Users.RemoveRange(context.Users);
            context.Applicants.RemoveRange(context.Applicants);
            context.JobOffers.RemoveRange(context.JobOffers);
            context.JobApplications.RemoveRange(context.JobApplications);
            context.Questions.RemoveRange(context.Questions);
            context.QuestionAnswers.RemoveRange(context.QuestionAnswers);
            context.SkillTags.RemoveRange(context.SkillTags);

            context.SaveChanges();

            #region employers

            RedHatEmployer = new Employer
            {
                Name         = "RedHat",
                Address      = "Brno, CzechRepublic",
                Email        = "*****@*****.**",
                PhoneNumber  = "+420 123 456 789",
                PasswordHash = "password",
                PasswordSalt = "password"
            };
            GoogleEmployer = new Employer
            {
                Name         = "Google",
                Address      = "MountainView, CA",
                Email        = "*****@*****.**",
                PhoneNumber  = "+421 123 456 789",
                PasswordHash = "password",
                PasswordSalt = "password"
            };

            MicrosoftEmployer = new Employer
            {
                Name         = "Microsoft",
                Address      = "Praha, CZ",
                Email        = "*****@*****.**",
                PhoneNumber  = "(425) 882-8080",
                PasswordHash = "password",
                PasswordSalt = "password"
            };

            context.Employers.Add(RedHatEmployer);
            context.Employers.Add(GoogleEmployer);
            context.Employers.Add(MicrosoftEmployer);

            #endregion

            #region skills

            CSharpSkill = new SkillTag {
                Name = "C#"
            };
            JavaSkill = new SkillTag {
                Name = "Java"
            };
            PhpSkill = new SkillTag {
                Name = "Php"
            };
            AngularSkill = new SkillTag {
                Name = "Angular"
            };
            AndroidSkill = new SkillTag {
                Name = "Android"
            };

            context.SkillTags.Add(CSharpSkill);
            context.SkillTags.Add(JavaSkill);
            context.SkillTags.Add(PhpSkill);
            context.SkillTags.Add(AngularSkill);
            context.SkillTags.Add(AndroidSkill);

            #endregion

            #region users

            PiskulaUser = new User
            {
                FirstName   = "Piskula",
                LastName    = "Zeleny",
                Email       = "*****@*****.**",
                PhoneNumber = "+420 123 456 789",
                Education   = "High School of Live",
                Skills      = new List <SkillTag>
                {
                    JavaSkill,
                    PhpSkill,
                    AngularSkill
                },
                PasswordHash = "password",
                PasswordSalt = "password"
            };

            MadkiUser = new User
            {
                FirstName   = "Madki",
                LastName    = "Programmer",
                Email       = "*****@*****.**",
                PhoneNumber = "+421 999 666 789",
                Education   = "Programming High",
                Skills      = new List <SkillTag>
                {
                    JavaSkill,
                    CSharpSkill,
                    AndroidSkill
                },
                PasswordHash = "password",
                PasswordSalt = "password"
            };

            AnonymousUser = new Applicant()
            {
                FirstName   = "Anonymous",
                LastName    = "Inkognito",
                Email       = "*****@*****.**",
                PhoneNumber = "+420 5565893",
                Education   = "Secret"
            };

            context.Applicants.Add(PiskulaUser);
            context.Applicants.Add(MadkiUser);
            context.Applicants.Add(AnonymousUser);

            #endregion

            #region questions

            JavaExperienceQuestion = new Question {
                Text = "What is your exeperience with Java programming?"
            };
            JavaEeExperienceQuestion = new Question {
                Text = "What is your exeperience with Java EE programming?"
            };
            CSharpExperienceQuestion = new Question {
                Text = "What is your exeperience with .Net programming?"
            };
            WebEprienceQuestion = new Question {
                Text = "What is your exeperience with web application programming?"
            };
            AndroidExperienceQuestion = new Question {
                Text = "What is your exeperience with Android programming?"
            };
            SoftSkillQuestion = new Question {
                Text = "Tell us about your soft skills"
            };
            HobbyQuesiton = new Question {
                Text = "What is your hobby?"
            };

            context.Questions.Add(JavaExperienceQuestion);
            context.Questions.Add(JavaEeExperienceQuestion);
            context.Questions.Add(CSharpExperienceQuestion);
            context.Questions.Add(WebEprienceQuestion);
            context.Questions.Add(AndroidExperienceQuestion);
            context.Questions.Add(SoftSkillQuestion);
            context.Questions.Add(HobbyQuesiton);

            #endregion

            #region job offers

            GoogleAndroidOffer = new JobOffer
            {
                Name        = "Associate Android Developer",
                Employer    = GoogleEmployer,
                Location    = "Paris, FR",
                Description = "Develop apps for Android - it will be fun!",
                Skills      = new List <SkillTag>
                {
                    JavaSkill,
                    AndroidSkill
                },
                Questions = new List <Question>
                {
                    SoftSkillQuestion,
                    JavaExperienceQuestion,
                    AndroidExperienceQuestion
                }
            };


            MicrosoftCSharpOffer = new JobOffer
            {
                Name        = "C# dev",
                Employer    = MicrosoftEmployer,
                Location    = "Seattle, WS",
                Description = "Lets see sharp!",
                Skills      = new List <SkillTag>
                {
                    CSharpSkill
                },
                Questions = new List <Question>
                {
                    CSharpExperienceQuestion
                }
            };

            MicrosoftManagerOffer = new JobOffer
            {
                Name        = "Project manager junior",
                Employer    = MicrosoftEmployer,
                Location    = "Seattle 2, WS",
                Description = "Manage amazing projects",
                Skills      = new List <SkillTag>
                {
                    CSharpSkill
                },
                Questions = new List <Question>
                {
                    SoftSkillQuestion,
                    HobbyQuesiton
                }
            };

            RedHatQualityOffer = new JobOffer
            {
                Name        = "Quality engineer",
                Employer    = RedHatEmployer,
                Location    = "Brno, CZ",
                Description = "Quality matters",
                Skills      = new List <SkillTag>
                {
                    JavaSkill
                },
                Questions = new List <Question>
                {
                    SoftSkillQuestion,
                    JavaExperienceQuestion,
                    JavaEeExperienceQuestion
                }
            };

            context.JobOffers.Add(GoogleAndroidOffer);
            context.JobOffers.Add(MicrosoftCSharpOffer);
            context.JobOffers.Add(MicrosoftManagerOffer);
            context.JobOffers.Add(RedHatQualityOffer);

            #endregion

            #region applications

            ApplicationRedHatQuality = new JobApplication
            {
                Applicant            = MadkiUser,
                JobOffer             = RedHatQualityOffer,
                JobApplicationStatus = JobApplicationStatus.Open
            };

            AnswersoftSkillsRedHat = new QuestionAnswer
            {
                Text        = "Great",
                Application = ApplicationRedHatQuality,
                Question    = SoftSkillQuestion
            };

            ÀnswersJavaRedHat = new QuestionAnswer
            {
                Text        = "Very Good",
                Application = ApplicationRedHatQuality,
                Question    = JavaExperienceQuestion
            };

            AnswerJavaEeRedHat = new QuestionAnswer
            {
                Text        = "Basic",
                Application = ApplicationRedHatQuality,
                Question    = JavaEeExperienceQuestion
            };

            ApplicationRedHatQuality.QuestionAnswers = new List <QuestionAnswer>
            {
                AnswersoftSkillsRedHat,
                ÀnswersJavaRedHat,
                AnswerJavaEeRedHat
            };


            context.QuestionAnswers.Add(AnswersoftSkillsRedHat);
            context.QuestionAnswers.Add(AnswerJavaEeRedHat);
            context.QuestionAnswers.Add(ÀnswersJavaRedHat);
            context.JobApplications.Add(ApplicationRedHatQuality);

            #endregion

            context.SaveChanges();

            return(context);
        }
Example #13
0
 public DefaultTenantBuilder(JobPortalDbContext context)
 {
     _context = context;
 }
Example #14
0
 public DefaultLanguagesCreator(JobPortalDbContext context)
 {
     _context = context;
 }
 public JobSettingsController(JobPortalDbContext context)
 {
     _context = context;
 }
Example #16
0
 public HostRoleAndUserCreator(JobPortalDbContext context)
 {
     _context = context;
 }
 public InitialHostDbBuilder(JobPortalDbContext context)
 {
     _context = context;
 }
Example #18
0
 public DefaultEditionCreator(JobPortalDbContext context)
 {
     _context = context;
 }