public bool UpdateSchoolLevel(string name, int levelNum, int id) { if (!String.IsNullOrEmpty(name)) { SchoolLevel schoolLevel = this.SchoolLevelRepository.GetByID(id); if (schoolLevel != null) { IEnumerable <SchoolLevel> oldSchoolLevels = this.SchoolLevelRepository.Get(s => s.Name == name).AsEnumerable(); if (oldSchoolLevels.Count() == 0) { schoolLevel.Name = name; schoolLevel.LevelNum = levelNum; this.SchoolLevelRepository.Update(schoolLevel); this.Save(); return(true); } else { if (oldSchoolLevels.ElementAt(0).IsDeleted == true) { oldSchoolLevels.ElementAt(0).IsDeleted = false; this.SchoolLevelRepository.Update(oldSchoolLevels.ElementAt(0)); schoolLevel.IsDeleted = true; this.SchoolLevelRepository.Update(schoolLevel); this.Save(); return(true); } } } } return(false); }
public IHttpActionResult PostSchoolLevel(SchoolLevel schoolLevel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SchoolLevels.Add(schoolLevel); try { db.SaveChanges(); } catch (DbUpdateException) { if (SchoolLevelExists(schoolLevel.LevelOfSchool)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = schoolLevel.LevelOfSchool }, schoolLevel)); }
public bool CreateSchoolLevel(string name, int levelNum) { if (!String.IsNullOrEmpty(name)) { SchoolLevel schoolLevel = this.SchoolLevelRepository.Get(s => s.Name == name).FirstOrDefault(); if (schoolLevel == null) { SchoolLevel newSchoolLevel = new SchoolLevel(); newSchoolLevel.Name = name; newSchoolLevel.LevelNum = levelNum; newSchoolLevel.IsDeleted = false; this.SchoolLevelRepository.Insert(newSchoolLevel); this.Save(); return(true); } else if (schoolLevel.IsDeleted == true) { schoolLevel.IsDeleted = false; schoolLevel.LevelNum = levelNum; this.SchoolLevelRepository.Update(schoolLevel); this.Save(); return(true); } return(false); } return(false); }
public IHttpActionResult PutSchoolLevel(string id, SchoolLevel schoolLevel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != schoolLevel.LevelOfSchool) { return(BadRequest()); } db.Entry(schoolLevel).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SchoolLevelExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <ActionResult> DeleteConfirmed(int id) { SchoolLevel schoolLevel = await db.SchoolLevels.FindAsync(id); db.SchoolLevels.Remove(schoolLevel); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public static SchoolLevelVm Build(SchoolLevel level) { return(new SchoolLevelVm { Key = level.Key, Name = level.Description, SortOrder = level.SortOrder }); }
public async Task <ActionResult> Edit([Bind(Include = "SchoolLevelId,Name")] SchoolLevel schoolLevel) { if (ModelState.IsValid) { db.Entry(schoolLevel).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(schoolLevel)); }
public IHttpActionResult GetSchoolLevel(string id) { SchoolLevel schoolLevel = db.SchoolLevels.Find(id); if (schoolLevel == null) { return(NotFound()); } return(Ok(schoolLevel)); }
public async Task <ActionResult> Create([Bind(Include = "SchoolLevelId,Name")] SchoolLevel schoolLevel) { if (ModelState.IsValid) { db.SchoolLevels.Add(schoolLevel); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(schoolLevel)); }
public bool DeleteSchoolLevel(int id) { SchoolLevel schoolLevel = this.SchoolLevelRepository.GetByID(id); if (schoolLevel != null) { schoolLevel.IsDeleted = true; this.SchoolLevelRepository.Update(schoolLevel); this.Save(); return(true); } return(false); }
public IHttpActionResult DeleteSchoolLevel(string id) { SchoolLevel schoolLevel = db.SchoolLevels.Find(id); if (schoolLevel == null) { return(NotFound()); } db.SchoolLevels.Remove(schoolLevel); db.SaveChanges(); return(Ok(schoolLevel)); }
// GET: SchoolLevels/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SchoolLevel schoolLevel = await db.SchoolLevels.FindAsync(id); if (schoolLevel == null) { return(HttpNotFound()); } return(View(schoolLevel)); }
public string GetClass() { if (SchoolLevel == SchoolLevel.Nursery) { string className = String.Empty; switch (Level) { case 0: className = "Daycare class"; break; case 1: className = "Baby class"; break; case 2: className = "Middle class"; break; case 3: className = "Pre-Primary class"; break; default: return(""); } if (HalfDay) { className = string.Format("{0} - Half Day", className); } return(className); } else { string level = SchoolLevel.ToString() ?? "Primary"; return(string.Format("{0} {1} - {2}", level, Level, Mode)); } }
public ActionResult Edit(SchoolLevel schoolLevel) { if (ModelState.IsValid) { db.Entry(schoolLevel). State = EntityState.Modified; var response = DBHelper.SaveChanges(db); if (response.Succeeded) { return(RedirectToAction("Index")); } ModelState. AddModelError( string.Empty, response.Message); } return(View(schoolLevel)); }
public ActionResult Create(SchoolLevel schoolLevel) { if (ModelState.IsValid) { db.SchoolLevels.Add(schoolLevel); var response = DBHelper.SaveChanges(db); if (response.Succeeded) { return(RedirectToAction("Index")); } ModelState. AddModelError( string.Empty, response.Message); } return(View(schoolLevel)); }
public bool CreateSchoolLevel(string name, int levelNum) { if (!String.IsNullOrEmpty(name)) { SchoolLevel schoolLevel = this.SchoolLevelRepository.Get(s => s.Name == name).FirstOrDefault(); if (schoolLevel == null) { SchoolLevel newSchoolLevel = new SchoolLevel(); newSchoolLevel.Name = name; newSchoolLevel.LevelNum = levelNum; newSchoolLevel.IsDeleted = false; this.SchoolLevelRepository.Insert(newSchoolLevel); this.Save(); return true; } else if (schoolLevel.IsDeleted == true) { schoolLevel.IsDeleted = false; schoolLevel.LevelNum = levelNum; this.SchoolLevelRepository.Update(schoolLevel); this.Save(); return true; } return false; } return false; }
public int Matching(int profileId, int jobId) { int matchingPercent = 0; Profile profile = this.ProfileRepository.GetByID(profileId); Job job = this.JobRepository.GetByID(jobId); if (profile != null && job != null) { // MinSalary - MaxSalary Nullable - 20 decimal expectedSalary = profile.ExpectedSalary; decimal?minSalary = job.MinSalary; decimal?maxSalary = job.MaxSalary; if (expectedSalary == 0 || (minSalary != null && maxSalary != null && minSalary <= expectedSalary && expectedSalary <= maxSalary) || (minSalary != null && maxSalary == null && minSalary <= expectedSalary) || (minSalary == null && maxSalary != null && expectedSalary <= maxSalary)) { matchingPercent += 20; } // JobLevel_ID - 20 JobLevel expectedJobLevel = this.JobLevelRepository.GetByID(profile.ExpectedJobLevel_ID); JobLevel jobLevel = this.JobLevelRepository.GetByID(job.JobLevel_ID); if (expectedJobLevel != null && jobLevel != null) { if (jobLevel.LevelNum >= expectedJobLevel.LevelNum) { matchingPercent += 20; } } // MinSchoolLevel_ID - 20 SchoolLevel highestSchoolLevel = this.SchoolLevelRepository.GetByID(profile.HighestSchoolLevel_ID); SchoolLevel minSchoolLevel = this.SchoolLevelRepository.GetByID(job.MinSchoolLevel_ID); if (highestSchoolLevel != null && minSchoolLevel != null) { if (highestSchoolLevel.LevelNum >= minSchoolLevel.LevelNum) { matchingPercent += 20; } } // Skill (nhieu TH) - 20 IEnumerable <int> jobSkillIdList = this.JobSkillRepository.Get(s => s.JobID == jobId && s.IsDeleted == false).Select(s => s.Skill_ID).AsEnumerable(); IEnumerable <int> ownSkillIdList = this.OwnSkillRepository.Get(s => s.JobSeekerID == profile.JobSeekerID && s.IsDeleted == false).Select(s => s.Skill_ID).AsEnumerable(); IEnumerable <int> skillIdIntersectList = jobSkillIdList.Intersect(ownSkillIdList); if (jobSkillIdList.Count() == 0) { matchingPercent += 20; } else if (skillIdIntersectList.Count() > 0) { matchingPercent += skillIdIntersectList.Count() * 20 / jobSkillIdList.Count(); } // Benefit (nhieu TH) - 20 //IEnumerable<int> jobBenefitIdList = this.JobBenefitRepository.Get(s => s.JobID == jobId && s.IsDeleted == false).Select(s => s.BenefitID).AsEnumerable(); //IEnumerable<int> desiredBenefit = this.DesiredBenefitRepository.Get(s => s.JobSeekerID == profile.JobSeekerID && s.IsDeleted == false).Select(s => s.BenefitID).AsEnumerable(); //IEnumerable<int> benefitIdIntersectList = jobBenefitIdList.Intersect(desiredBenefit); //if (jobBenefitIdList.Count() == 0) //{ // matchingPercent += 20; //} //if (benefitIdIntersectList.Count() > 0) //{ // matchingPercent += benefitIdIntersectList.Count() * 20 / jobBenefitIdList.Count(); //} // Category - 10 IEnumerable <int> jobCategoryIdList = this.JobCategoryRepository.Get(s => s.JobID == jobId && s.IsDeleted == false).Select(s => s.CategoryID).AsEnumerable(); IEnumerable <int> expectedCategoryIdList = this.ExpectedCategoryRepository.Get(s => s.ProfileID == profileId && s.IsDeleted == false).Select(s => s.CategoryID).AsEnumerable(); IEnumerable <int> categoryIdIntersectList = jobCategoryIdList.Intersect(expectedCategoryIdList); if (categoryIdIntersectList.Count() > 0) { matchingPercent += 10; } // City - 10 IEnumerable <int> jobCityIdList = this.JobCityRepository.Get(s => s.JobID == jobId && s.IsDeleted == false).Select(s => s.CityID).AsEnumerable(); IEnumerable <int> expectedCityIdList = this.ExpectedCityRepository.Get(s => s.ProfileID == profileId && s.IsDeleted == false).Select(s => s.CityID).AsEnumerable(); IEnumerable <int> cityIdIntersectList = jobCityIdList.Intersect(expectedCityIdList); if (cityIdIntersectList.Count() > 0) { matchingPercent += 10; } } return(matchingPercent); }
public List <SosanhItem> GetMatchingDetail(int profileId, int jobId) { List <SosanhItem> matchingDetail = new List <SosanhItem>(); Profile profile = this.ProfileRepository.GetByID(profileId); Job job = this.JobRepository.GetByID(jobId); if (profile != null && job != null) { int tong = 0; // MinSalary - MaxSalary Nullable - 20 decimal expectedSalary = profile.ExpectedSalary; decimal? minSalary = job.MinSalary; decimal? maxSalary = job.MaxSalary; SosanhItem sosanh1 = new SosanhItem(); sosanh1.columnName = "Mức lương"; sosanh1.tyle = 20; if (minSalary == null && maxSalary == null) { sosanh1.jobInfo = "Thỏa thuận"; } else { sosanh1.jobInfo = "$" + String.Format("{0:#.00}", minSalary) + " => $" + String.Format("{0:#.00}", maxSalary); } if (expectedSalary == 0) { sosanh1.applicantInfo = "Thỏa thuận"; } else { sosanh1.applicantInfo = "$" + String.Format("{0:#.00}", expectedSalary); } if (expectedSalary == 0 || (minSalary != null && maxSalary != null && minSalary <= expectedSalary && expectedSalary <= maxSalary) || (minSalary != null && maxSalary == null && minSalary <= expectedSalary) || (minSalary == null && maxSalary != null && expectedSalary <= maxSalary)) { sosanh1.isSatisfied = true; tong += 20; } else { sosanh1.isSatisfied = false; } matchingDetail.Add(sosanh1); // JobLevel_ID - 20 JobLevel expectedJobLevel = this.JobLevelRepository.GetByID(profile.ExpectedJobLevel_ID); JobLevel jobLevel = this.JobLevelRepository.GetByID(job.JobLevel_ID); SosanhItem sosanh2 = new SosanhItem(); sosanh2.columnName = "Vị trí"; sosanh2.tyle = 20; sosanh2.jobInfo = jobLevel.Name; sosanh2.applicantInfo = expectedJobLevel.Name; if (expectedJobLevel != null && jobLevel != null) { if (jobLevel.LevelNum >= expectedJobLevel.LevelNum) { sosanh2.isSatisfied = true; tong += 20; } else { sosanh2.isSatisfied = false; } } matchingDetail.Add(sosanh2); // MinSchoolLevel_ID - 20 SchoolLevel highestSchoolLevel = this.SchoolLevelRepository.GetByID(profile.HighestSchoolLevel_ID); SchoolLevel minSchoolLevel = this.SchoolLevelRepository.GetByID(job.MinSchoolLevel_ID); SosanhItem sosanh3 = new SosanhItem(); sosanh3.columnName = "Trình độ"; sosanh3.tyle = 20; sosanh3.jobInfo = minSchoolLevel.Name; sosanh3.applicantInfo = highestSchoolLevel.Name; if (highestSchoolLevel != null && minSchoolLevel != null) { if (highestSchoolLevel.LevelNum >= minSchoolLevel.LevelNum) { sosanh3.isSatisfied = true; tong += 20; } else { sosanh3.isSatisfied = false; } } matchingDetail.Add(sosanh3); // Skill (nhieu TH) - 20 IEnumerable <int> jobSkillIdList = this.JobSkillRepository.Get(s => s.JobID == jobId && s.IsDeleted == false).Select(s => s.Skill_ID).AsEnumerable(); IEnumerable <int> ownSkillIdList = this.OwnSkillRepository.Get(s => s.JobSeekerID == profile.JobSeekerID && s.IsDeleted == false).Select(s => s.Skill_ID).AsEnumerable(); IEnumerable <int> skillIdIntersectList = jobSkillIdList.Intersect(ownSkillIdList); SosanhItem sosanh4 = new SosanhItem(); sosanh4.columnName = "Kỹ năng"; sosanh4.tyle = 20; if (jobSkillIdList.Count() == 0) { sosanh4.jobInfo = "Không yêu cầu"; } else { sosanh4.jobInfo = this.SkillRepository.GetByID(jobSkillIdList.ElementAt(0)).SkillTag; for (int i = 1; i < jobSkillIdList.Count(); i++) { sosanh4.jobInfo += ", " + this.SkillRepository.GetByID(jobSkillIdList.ElementAt(i)).SkillTag; } } if (ownSkillIdList.Count() == 0) { sosanh4.applicantInfo = "Không có"; } else { if (jobSkillIdList.Contains(ownSkillIdList.ElementAt(0))) { sosanh4.applicantInfo = this.SkillRepository.GetByID(ownSkillIdList.ElementAt(0)).SkillTag; } else { sosanh4.applicantInfo = "<span style='color: red'>" + this.SkillRepository.GetByID(ownSkillIdList.ElementAt(0)).SkillTag + "</span>"; } for (int i = 1; i < ownSkillIdList.Count(); i++) { if (jobSkillIdList.Contains(ownSkillIdList.ElementAt(i))) { sosanh4.applicantInfo += ", " + this.SkillRepository.GetByID(ownSkillIdList.ElementAt(i)).SkillTag; } else { sosanh4.applicantInfo += ", " + "<span style='color: red'>" + this.SkillRepository.GetByID(ownSkillIdList.ElementAt(i)).SkillTag + "</span>"; } } } if (jobSkillIdList.Count() == 0) { sosanh4.isSatisfied = true; tong += 20; } else if (skillIdIntersectList.Count() > 0) { sosanh4.isSatisfied = true; tong += skillIdIntersectList.Count() * 20 / jobSkillIdList.Count(); } else { sosanh4.isSatisfied = false; } matchingDetail.Add(sosanh4); // Benefit (nhieu TH) - 20 //IEnumerable<int> jobBenefitIdList = this.JobBenefitRepository.Get(s => s.JobID == jobId && s.IsDeleted == false).Select(s => s.BenefitID).AsEnumerable(); //IEnumerable<int> desiredBenefit = this.DesiredBenefitRepository.Get(s => s.JobSeekerID == profile.JobSeekerID && s.IsDeleted == false).Select(s => s.BenefitID).AsEnumerable(); //IEnumerable<int> benefitIdIntersectList = jobBenefitIdList.Intersect(desiredBenefit); //SosanhItem sosanh5 = new SosanhItem(); //sosanh5.columnName = "Phúc lợi"; //if (jobBenefitIdList.Count() == 0) //{ // sosanh5.jobInfo = "Không hỗ trợ"; //} //else //{ // sosanh5.jobInfo = this.BenefitRepository.GetByID(jobBenefitIdList.ElementAt(0)).Name; // for (int i = 1; i < jobBenefitIdList.Count(); i++) // { // sosanh5.jobInfo += ", " + this.BenefitRepository.GetByID(jobBenefitIdList.ElementAt(i)).Name; // } //} //if (desiredBenefit.Count() == 0) //{ // sosanh5.applicantInfo = "Không yêu cầu"; //} //else //{ // sosanh5.applicantInfo = this.BenefitRepository.GetByID(desiredBenefit.ElementAt(0)).Name; // for (int i = 1; i < desiredBenefit.Count(); i++) // { // sosanh5.applicantInfo += ", " + this.BenefitRepository.GetByID(desiredBenefit.ElementAt(i)).Name; // } //} //if (jobBenefitIdList.Count() == 0 || benefitIdIntersectList.Count() > 0) //{ // sosanh5.isSatisfied = true; //} //else //{ // sosanh5.isSatisfied = false; //} //matchingDetail.Add(sosanh5); // Category - 10 IEnumerable <int> jobCategoryIdList = this.JobCategoryRepository.Get(s => s.JobID == jobId && s.IsDeleted == false).Select(s => s.CategoryID).AsEnumerable(); IEnumerable <int> expectedCategoryIdList = this.ExpectedCategoryRepository.Get(s => s.ProfileID == profileId && s.IsDeleted == false).Select(s => s.CategoryID).AsEnumerable(); IEnumerable <int> categoryIdIntersectList = jobCategoryIdList.Intersect(expectedCategoryIdList); SosanhItem sosanh6 = new SosanhItem(); sosanh6.columnName = "Ngành nghề"; sosanh6.tyle = 10; if (jobCategoryIdList.Count() == 0) { sosanh6.jobInfo = "Không có"; } else { sosanh6.jobInfo = this.CategoryRepository.GetByID(jobCategoryIdList.ElementAt(0)).Name; for (int i = 1; i < jobCategoryIdList.Count(); i++) { sosanh6.jobInfo += ", " + this.CategoryRepository.GetByID(jobCategoryIdList.ElementAt(i)).Name; } } if (expectedCategoryIdList.Count() == 0) { sosanh6.applicantInfo = "Không yêu cầu"; } else { sosanh6.applicantInfo = this.CategoryRepository.GetByID(expectedCategoryIdList.ElementAt(0)).Name; for (int i = 1; i < expectedCategoryIdList.Count(); i++) { sosanh6.applicantInfo += ", " + this.CategoryRepository.GetByID(expectedCategoryIdList.ElementAt(i)).Name; } } if (categoryIdIntersectList.Count() > 0) { sosanh6.isSatisfied = true; tong += 10; } else { sosanh6.isSatisfied = false; } matchingDetail.Add(sosanh6); // City - 10 IEnumerable <int> jobCityIdList = this.JobCityRepository.Get(s => s.JobID == jobId && s.IsDeleted == false).Select(s => s.CityID).AsEnumerable(); IEnumerable <int> expectedCityIdList = this.ExpectedCityRepository.Get(s => s.ProfileID == profileId && s.IsDeleted == false).Select(s => s.CityID).AsEnumerable(); IEnumerable <int> cityIdIntersectList = jobCityIdList.Intersect(expectedCityIdList); SosanhItem sosanh7 = new SosanhItem(); sosanh7.columnName = "Thành phố"; sosanh7.tyle = 10; if (jobCityIdList.Count() == 0) { sosanh7.jobInfo = "Không có"; } else { sosanh7.jobInfo = this.CityRepository.GetByID(jobCityIdList.ElementAt(0)).Name; for (int i = 1; i < jobCityIdList.Count(); i++) { sosanh7.jobInfo += ", " + this.CityRepository.GetByID(jobCityIdList.ElementAt(i)).Name; } } if (expectedCityIdList.Count() == 0) { sosanh7.applicantInfo = "Không có"; } else { sosanh7.applicantInfo = this.CityRepository.GetByID(expectedCityIdList.ElementAt(0)).Name; for (int i = 1; i < expectedCityIdList.Count(); i++) { sosanh7.applicantInfo += ", " + this.CityRepository.GetByID(expectedCityIdList.ElementAt(i)).Name; } } if (cityIdIntersectList.Count() > 0) { sosanh7.isSatisfied = true; tong += 10; } else { sosanh7.isSatisfied = false; } matchingDetail.Add(sosanh7); // Tong SosanhItem sosanhtong = new SosanhItem(); sosanhtong.columnName = ""; sosanhtong.jobInfo = "Tổng:"; sosanhtong.applicantInfo = tong.ToString() + "%"; sosanhtong.isSatisfied = true; sosanhtong.tyle = 100; matchingDetail.Add(sosanhtong); } return(matchingDetail); }