/// <summary> /// sets rating of vacancyemployee (like / dislike) /// </summary> /// <returns></returns> public object setRating() { try { var headers = Request.Headers; int employeeID = (headers.Contains("employeeID")) ? Int32.Parse(headers.GetValues("employeeID").First()) : -1; int vacancyID = (headers.Contains("vacancyID")) ? Int32.Parse(headers.GetValues("vacancyID").First()) : -1; int rating = (headers.Contains("rating")) ? Int32.Parse(headers.GetValues("rating").First()) : -99; WorQitEntities wqdb = new WorQitEntities(); wqdb.Configuration.ProxyCreationEnabled = false; VacancyEmployee vac = (from VacancyEmployee in wqdb.VacancyEmployees where VacancyEmployee.employeeID == employeeID && VacancyEmployee.vacancyID == vacancyID select VacancyEmployee).First(); vac.rating = rating; wqdb.SaveChanges(); return(Json(new { Result = "successful" })); } catch (Exception ex) { return(Json(new { Result = "failed", Error = ex })); } }
/// <summary> /// matching algorythm /// </summary> /// <param name="employeeID"></param> /// <param name="vacancyID"></param> private void setMatchScore(int employeeID, int vacancyID) { int bedrijfsScore = 0; WorQitEntities wqdb = new WorQitEntities(); wqdb.Configuration.ProxyCreationEnabled = false; Vacancy vacancy = wqdb.Vacancies.Where(x => x.ID == vacancyID).First(); Employee employee = wqdb.Employees.Where(x => x.ID == employeeID).First(); List <Vacancy> vacancies = wqdb.Vacancies.Where(x => x.employerID == vacancy.employerID).ToList(); foreach (Vacancy v in vacancies) { List <VacancyEmployee> vList = wqdb.VacancyEmployees.Where(x => x.vacancyID == v.ID).ToList(); foreach (VacancyEmployee ve in vList) { bedrijfsScore = ve.rating ?? default(int); } if (bedrijfsScore > -5) { int matchScore = 0; if (employee.industry != null) { if (v.branche.Contains(employee.industry)) { matchScore = matchScore + 10; } } if (employee.positions != null) { if (v.jobfunction.Contains(employee.positions)) { matchScore = matchScore + 5; } } if (employee.skills != null) { if (v.requirements.Contains(employee.skills)) { matchScore = matchScore + 7; } } if (employee.educations != null) { if (v.educations.Contains(employee.educations)) { matchScore = matchScore + 9; } } var ve = wqdb.VacancyEmployees.Where(x => x.employeeID == employee.ID).Where(x => x.vacancyID == v.ID).FirstOrDefault(); if (ve == null) { VacancyEmployee newVE = new VacancyEmployee() { employeeID = employee.ID, vacancyID = v.ID, matchingValue = matchScore, rating = 0 }; wqdb.VacancyEmployees.Add(newVE); wqdb.SaveChanges(); } else { ve.matchingValue = matchScore; } } } }