Ejemplo n.º 1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new ApplicantDBContext(serviceProvider.GetRequiredService <DbContextOptions <ApplicantDBContext> >()))
            {
                // Look for any board games already in database.
                if (context.Applicants.Any())
                {
                    return;   // Database has been seeded
                }
                else
                {
                    //else seed a sample applicant into the database
                    context.Applicants.Add(
                        new Applicant
                    {
                        Id              = 1,
                        Name            = "Tobias",
                        FamilyName      = "Bodmann",
                        Address         = "Friedhofstraße 11, 93142 Maxhütte-Haidhof, Germany",
                        EmailAdress     = "*****@*****.**",
                        Age             = 28,
                        CountryOfOrigin = "Germany",
                        Hired           = true
                    });

                    context.SaveChanges();
                }
            }
        }
Ejemplo n.º 2
0
 public ApplicantController(ApplicantDBContext applicantDBContext,
                            ILoggerFactory loggerFactory,
                            IHttpContextAccessor httpContextAccessor)
 {
     _context             = applicantDBContext;
     _httpContextAccessor = httpContextAccessor;
     _microsoftlogger     = loggerFactory.CreateLogger("Microsoft");
     _systemlogger        = loggerFactory.CreateLogger("System");
 }
Ejemplo n.º 3
0
        public ActionResult ViewPotentialApplicant(String name, String email, String jobTitle, String dateTime)
        {
            ApplicantDBContext dbApplicant = new ApplicantDBContext();
            Applicant          applicant   = dbApplicant.Applicants.Find(email);

            ViewBag.Image = Url.Content(applicant.Path2Photo);
            //ViewBag.Image = @"C:\Users\Marlon\Source\Repos\career-matcher\Careermatcher\FolderOfApplicants\[email protected]\Profile";
            //String path= Server.MapPath(applicant.Path2Photo));
            //var dir = new System.IO.DirectoryInfo(Server.MapPath(applicant.Path2Photo));
            return(View(applicant));
        }
        public async Task ApplicantController_Update_And_GetAll()
        {
            var inMemoryDataContextOptions = new DbContextOptionsBuilder <ApplicantDBContext>()
                                             .UseInMemoryDatabase(databaseName: "Test_With_In_Memory_Database")
                                             .Options;

            var            mockLogger = new Mock <ILoggerFactory>();
            ILoggerFactory logger     = mockLogger.Object;



            var mockHttpContextAccessor = new Mock <IHttpContextAccessor>();
            var context = new DefaultHttpContext();



            mockHttpContextAccessor.Setup(_ => _.HttpContext).Returns(context);
            //Mock HeaderConfiguration
            IHttpContextAccessor httpContextAccessor = mockHttpContextAccessor.Object;

            var controllerContext = new ControllerContext()
            {
                HttpContext = context,
            };
            var applicantDBContext = new ApplicantDBContext(inMemoryDataContextOptions);
            var controller         = new ApplicantController(applicantDBContext, logger, httpContextAccessor)
            {
                ControllerContext = controllerContext
            };
            var newApplicant = new Applicant()
            {
                Address        = "Test",
                Age            = 24,
                CountryOfOrgin = "Uk",
                Email          = "*****@*****.**",
                Family         = "contoso",
                IsHired        = true,
                Name           = "Anoop"
            };

            var applicant = await controller.Post(newApplicant);

            Assert.IsInstanceOfType(applicant, typeof(Tuple <Applicant, Link>));


            newApplicant.Age = 30;

            await controller.Put(newApplicant.ID, newApplicant);


            var applicantlist = await controller.Get(newApplicant.ID);

            Assert.AreEqual(applicantlist.Age, 30);
        }
Ejemplo n.º 5
0
        public ActionResult getJobAndEducationInformation(String Title, String[] groupselect, String[] groupselect2)
        {
            //This needs to be changed
            ApplicantDBContext Applicantdb = new ApplicantDBContext();
            Applicant          applicant   = Applicantdb.Applicants.Find(User.Identity.Name);

            applicant.Education                = string.Join("|", groupselect);
            applicant.IntrestedJobs            = string.Join("|", groupselect2);
            Applicantdb.Entry(applicant).State = EntityState.Modified;
            Applicantdb.SaveChanges();
            return(RedirectToAction("Index", "Applicant", new { area = "" }));
        }
        public async Task ApplicantController_CheckForRetunType_of_GetAll()
        {
            var inMemoryDataContextOptions = new DbContextOptionsBuilder <ApplicantDBContext>()
                                             .UseInMemoryDatabase(databaseName: "Test_With_In_Memory_Database")
                                             .Options;

            var            mockLogger = new Mock <ILoggerFactory>();
            ILoggerFactory logger     = mockLogger.Object;

            var mockHttpContextAccesor = new Mock <IHttpContextAccessor>();
            IHttpContextAccessor httpContextAccessor = mockHttpContextAccesor.Object;



            var applicantDBContext = new ApplicantDBContext(inMemoryDataContextOptions);
            var controller         = new ApplicantController(applicantDBContext, logger, httpContextAccessor);


            Assert.IsInstanceOfType(await controller.GetAll(), typeof(IEnumerable <Applicant>));
        }
 public ApplicantService(ApplicantDBContext ctx, ILogger <ApplicantService> logger = null)
 {
     _context = ctx;
     _logger  = logger;
 }
Ejemplo n.º 8
0
        public ActionResult eligibleApplicants(String id, String Hour, String Minute, String Seconds, String Millisecond, String Ticks, String jobTitle, String tags, String education, String time)
        {
            //http://stackoverflow.com/questions/1757214/linq-entity-string-field-contains-any-of-an-array-of-strings
            ApplicantDBContext dbApplicant = new ApplicantDBContext();
            //String test = { "mustard", "pickles", "relish" };
            //var possible = dbApplicant.Applicants.Any(x => (x.Education.Contains(education)));
            //var possible = from p in dbApplicant.Applicants
            //               where search.Any(x=>p.Education.Contains);
            var requriedEducationarray     = education.Split('|');
            var requriedIntrestedJobsarray = tags.Split('|');
            //var test = dbApplicant.Applicants.Any(str => str.Education.Split('|').Intersect(education.Split('|')).Any());
            var result = from p in dbApplicant.Applicants
                         where requriedEducationarray.Any(val => p.Education.Contains(val))
                         select p;
            var result2 = from p in result
                          where requriedIntrestedJobsarray.Any(val => p.IntrestedJobs.Contains(val))
                          select p;


            MatchDBContext dbMatch        = new MatchDBContext();
            CultureInfo    provider       = CultureInfo.InvariantCulture;
            DateTime       jobPublishdate = DateTime.ParseExact(time, "MM/dd/yyyy HHH:mm:ss", provider);
            String         theDate        = jobPublishdate.ToString();

            //old matches
            //var thisEmployersMatches = dbMatch.Matches.Where(x => (x.EmployerEmailAddress.Equals(User.Identity.Name))).Select(x => x.ApplicantEmailAddress).ToArray();
            //Filtering based on employer id and the job title
            var thisEmployersMatches = dbMatch.Matches.Where(x => ((x.EmployerEmailAddress.Equals(User.Identity.Name)) &&
                                                                   (x.JobTitle.Equals(jobTitle))));

            //Filtering based on job pubish date as it a unique identifier
            var filteredBasedOnJobPublishedDate = thisEmployersMatches.Where(x => x.PublishDate.Equals(theDate));

            ///////////For filtering  rejected Applicants to display ONLY FOR returning to view//////////////

            // Only showing matches which were not rejected by this employer
            var filteredBasedOnRejectedByEmployer = filteredBasedOnJobPublishedDate.Where(x => x.rejectedByEmployer == false);
            // Only showing matches which were not rejected by an applicant
            var filteredBasedOnRejectedByApplicantList = filteredBasedOnRejectedByEmployer.Where(x => x.rejectedByEmployer == false);
            //list of Applicant names that were not rejected
            //var listOfNonRejectedApplicantNames = filteredBasedOnRejectedByApplicantList.Select(x => x.ApplicantEmailAddress).ToList();


            //////////////////////////////////////////////
            //Gives a list of applicants to ignore for adding to the db
            var listOfExisingApplicantNames = filteredBasedOnJobPublishedDate.Select(x => x.ApplicantEmailAddress).ToArray();
            //var all = amp.Select(x =>x.ApplicantEmailAddress);
            //var result2filtered = ;

            var result4 = from p in result2
                          where !listOfExisingApplicantNames.Any(val => p.email.Contains(val))
                          select p;

            if (result4.Count() == 0)
            {
                //var test1 = thisEmployersMatches.ToList();
                //var test2 = listOfNonRejectedApplicantNames;
                return(View(filteredBasedOnRejectedByApplicantList.ToList()));
            }



            foreach (var item in result4)
            {
                //int count = requriedEducationarray.Where(val => item.Education.Contains(val)).Count();
                var educationListOfCurrentApplicant = item.Education.Split('|');
                var countSimilarityEducation        = requriedEducationarray.Intersect(educationListOfCurrentApplicant).Count();

                var intrestedJobsListOfCurrentApplicant = item.IntrestedJobs.Split('|');
                var countSimilarityIntrestedJobs        = requriedIntrestedJobsarray.Intersect(intrestedJobsListOfCurrentApplicant).Count();
                //calculating score////
                var startScore = 5;
                var a1         = requriedEducationarray.Length - countSimilarityEducation;
                var a2         = requriedIntrestedJobsarray.Length - countSimilarityIntrestedJobs;
                var overAll    = startScore - (a1 + a2);

                Match match = new Match
                {
                    EmployerEmailAddress  = User.Identity.Name,
                    JobTitle              = jobTitle,
                    ApplicantEmailAddress = item.email,
                    PublishDate           = jobPublishdate.ToString(),
                    ApplicantName         = item.firstName + " " + item.lastName,
                    overAllScore          = overAll,
                    acceptedByApplicant   = false,
                    acceptedByEmployer    = false,
                    rejectedByApplicant   = false,
                    rejectedByEmployer    = false
                };

                dbMatch.Matches.Add(match);
            }
            dbMatch.SaveChanges();

            //return View(dbMatch.Matches.ToList());
            return(View(filteredBasedOnRejectedByApplicantList.ToList()));
        }