public ActionResult Resume() { var vm = new ResumeViewModel() { ApplicantModel = new ApplicantModel() { ApplicantId = 0, NationalityCd = "MYS" } }; var login = ObjectBuilder.GetObject<ILoginUserPersistance>("LoginUserPersistance").GetByUserName(User.Identity.Name); if (null != login) { vm.ApplicantModel.FullName = login.FullName; vm.ApplicantModel.Email = login.Email; vm.ApplicantModel.NewIcNo = login.LoginId; if (login.ApplicantId.HasValue && login.ApplicantId.Value != 0) { var applicant = ObjectBuilder.GetObject<IApplicantPersistence>("ApplicantPersistence").GetApplicant(login.ApplicantId.Value); if (null != applicant) { vm.ApplicantModel = new ApplicantModel(applicant, 0); } } // get all high education level var refrepos = new ReferenceRepo(); var he = refrepos.GetHighEduLevels(); if (he.Any()) { he = he.OrderBy(a => a.IndexNo); foreach (var h in he) { var edu = new ApplicantEducation() { HighEduLevelCd = h.HighEduLevelCd, HighEduLevel = h.HighestEduLevel }; if (h.HighEduLevelCd == "14") { var subjects = refrepos.GetSubjects(h.HighEduLevelCd); if (subjects.Any()) foreach (var s in subjects) edu.ApplicantEduSubjectCollection.Add(new ApplicantEduSubject() { SubjectCd = s.SubjectCd, Subject = s.SubjectDescription }); } vm.ApplicantModel.ApplicantEducations.Add(edu); } } } var repos = new ReferenceRepo(); vm.MaritalStatuses.AddRange(repos.GetMaritalStatus()); return View(vm); }
public int UpdateEducation(ApplicantEducation education) { using (var entities = new atmEntities()) { var exist = (from a in entities.tblApplicantEdus where a.ApplicantEduId == education.ApplicantEduId select a).SingleOrDefault(); if (exist != null) { exist.ApplicantId = education.ApplicantId; exist.ConfermentYr = education.ConfermentYr; exist.EduCertTitle = education.EduCertTitle; exist.HighEduLevelCd = !string.IsNullOrWhiteSpace(education.HighEduLevelCd) ? education.HighEduLevelCd.Trim() : education.HighEduLevelCd; exist.InstCd = !string.IsNullOrWhiteSpace(education.InstCd) ? education.InstCd.Trim() : education.InstCd; exist.InstitutionName = education.InstitutionName; exist.LastModifiedBy = education.LastModifiedBy; exist.LastModifiedDt = DateTime.Now; exist.MajorMinorCd = !string.IsNullOrWhiteSpace(education.MajorMinorCd) ? education.MajorMinorCd.Trim() : education.MajorMinorCd; exist.OverSeaInd = education.OverSeaInd; exist.OverallGrade = education.OverallGrade; exist.SKMLevel = education.SKMLevel; entities.SaveChanges(); return exist.ApplicantEduId; } } return 0; }
public IEnumerable<ApplicantEducation> GetEducation(int applicantid) { var list = new List<ApplicantEducation>(); using (var entities = new atmEntities()) { var l = from a in entities.tblApplicantEdus where a.ApplicantId == applicantid select a; if (l.Any()) { foreach (var aes in l) { var ed = new ApplicantEducation { ApplicantEduId = aes.ApplicantEduId, ApplicantId = aes.ApplicantId, ConfermentYr = aes.ConfermentYr, CreatedBy = aes.CreatedBy, CreatedDt = aes.CreatedDt, EduCertTitle = aes.EduCertTitle, HighEduLevel = aes.tblREFHighEduLevel != null ? aes.tblREFHighEduLevel.HighestEduLevel : string.Empty, HighEduLevelCd = !string.IsNullOrWhiteSpace(aes.HighEduLevelCd) ? aes.HighEduLevelCd.Trim() : aes.HighEduLevelCd, InstCd = !string.IsNullOrWhiteSpace(aes.InstCd) ? aes.InstCd.Trim() : aes.InstCd, InstitutionName = aes.InstitutionName, LastModifiedBy = aes.LastModifiedBy, LastModifiedDt = aes.LastModifiedDt, MajorMinorCd = !string.IsNullOrWhiteSpace(aes.MajorMinorCd) ? aes.MajorMinorCd.Trim() : aes.MajorMinorCd, OverSeaInd = aes.OverSeaInd, OverallGrade = aes.OverallGrade, SKMLevel = aes.SKMLevel }; if (aes.tblApplicantEduSubjects.Any()) { foreach (var s in aes.tblApplicantEduSubjects) { ed.ApplicantEduSubjectCollection.Add(new ApplicantEduSubject { ApplicantEduId = s.ApplicantEduId, CreatedBy = s.CreatedBy, CreatedDt = s.CreatedDt, EduSubjectId = s.EduSubjectId, Grade = s.tblREFSubjectGrade.Grade, GradeCd = !string.IsNullOrWhiteSpace(s.GradeCd) ? s.GradeCd.Trim() : s.GradeCd, LastModifiedBy = s.LastModifiedBy, LastModifiedDt = s.LastModifiedDt, Subject = s.tblREFSubject.Subject, SubjectCd = s.SubjectCd }); } } list.Add(ed); } } } return list; }
public int SaveEducation(ApplicantEducation education) { using (var entities = new atmEntities()) { var exist = (from a in entities.tblApplicantEdus where a.ApplicantId == education.ApplicantId && a.HighEduLevelCd == education.HighEduLevelCd select a).SingleOrDefault(); if (exist != null) { education.ApplicantEduId = exist.ApplicantEduId; return UpdateEducation(education); } if (education.ApplicantEduId != 0) { return UpdateEducation(education); } var ed = new tblApplicantEdu { ApplicantId = education.ApplicantId, ConfermentYr = education.ConfermentYr, CreatedBy = education.CreatedBy, CreatedDt = education.CreatedDt, EduCertTitle = education.EduCertTitle, HighEduLevelCd = !string.IsNullOrWhiteSpace(education.HighEduLevelCd) ? education.HighEduLevelCd.Trim() : education.HighEduLevelCd, InstCd = !string.IsNullOrWhiteSpace(education.InstCd) ? education.InstCd.Trim() : education.InstCd, InstitutionName = education.InstitutionName, MajorMinorCd = !string.IsNullOrWhiteSpace(education.MajorMinorCd) ? education.MajorMinorCd.Trim() : education.MajorMinorCd, OverSeaInd = education.OverSeaInd, OverallGrade = education.OverallGrade, SKMLevel = education.SKMLevel }; entities.tblApplicantEdus.Add(ed); if (entities.SaveChanges() > 0) return ed.ApplicantEduId; } return 0; }
public ApplicantModel(Applicant app, int acquisitionid) { ApplicantId = app.ApplicantId; NewIcNo = app.NewICNo; NoTentera = app.NoTentera; FullName = app.FullName; MrtlStatusCd = app.MrtlStatusCd; GenderCd = app.GenderCd; Height = app.Height; Weight = app.Weight; Bmi = app.BMI; NationalityCd = app.NationalityCd; NationalityCertNo = app.NationalityCertNo; BirthCertNo = app.BirthCertNo; ReligionCd = app.ReligionCd; RaceCd = app.RaceCd; EthnicCd = !string.IsNullOrWhiteSpace(app.EthnicCd) ? app.EthnicCd.Trim() : app.EthnicCd; BirthCountryCd = app.BirthCountryCd; BirthStateCd = app.BirthStateCd; BirthCityCd = !string.IsNullOrWhiteSpace(app.BirthCityCd) ? app.BirthCityCd.Trim() : app.BirthCityCd; BirthPlace = app.BirthPlace; BloodTypeCd = app.BloodTypeCd; SpectaclesUserInd = app.SpectaclesUserInd; ColorBlindInd = app.ColorBlindInd; ResidenceTypeInd = app.ResidenceTypeInd; CorresponAddr1 = app.CorresponAddr1; CorresponAddr2 = app.CorresponAddr2; CorresponAddr3 = app.CorresponAddr3; CorresponAddrPostCd = app.CorresponAddrPostCd; CorresponAddrCityCd = !string.IsNullOrWhiteSpace(app.CorresponAddrCityCd) ? app.CorresponAddrCityCd.Trim() : app.CorresponAddrCityCd; CorresponAddrStateCd = app.CorresponAddrStateCd; CorresponAddrCountryCd = app.CorresponAddrCountryCd; MobilePhoneNo = app.MobilePhoneNo; HomePhoneNo = app.HomePhoneNo; Email = app.Email; ChildNo = app.ChildNo; NoOfSibling = app.NoOfSibling; MomName = app.MomName; MomIcNo = app.MomICNo; MomNationalityCd = app.MomNationalityCd; MomOccupation = app.MomOccupation; MomSalary = app.MomSalary; MomPhoneNo = app.MomPhoneNo; DadName = app.DadName; DadIcNo = app.DadICNo; DadNationalityCd = app.DadNationalityCd; DadOccupation = app.DadOccupation; DadSalary = app.DadSalary; DadPhoneNo = app.DadPhoneNo; GuardianName = app.GuardianName; GuardianIcNo = app.GuardianICNo; GuardianNationalityCd = app.GuardianNationalityCd; GuardianOccupation = app.GuardianOccupation; GuardianSalary = app.GuardianSalary; GuardianPhoneNo = app.GuardianPhoneNo; FamilyHighestEduLevel = app.FamilyHighestEduLevel; CurrentOccupation = app.CurrentOccupation; CurrentOrganisation = app.CurrentOrganisation; CurrentSalary = app.CurrentSalary; PalapesInd = app.PalapesInd ?? false; PalapesYear = app.PalapesYear; PalapesArmyNo = app.PalapesArmyNo; PalapesInstitution = app.PalapesInstitution; PalapesRemark = app.PalapesRemark; PalapesTauliahEndDt = app.PalapesTauliahEndDt; ScholarshipInd = app.ScholarshipInd ?? false; ScholarshipBody = app.ScholarshipBody; ScholarshipBodyAddr = app.ScholarshipBodyAddr; ScholarshipNoOfYrContract = app.ScholarshipNoOfYrContract; ArmySelectionInd = app.ArmySelectionInd ?? false; ArmySelectionVenue = app.ArmySelectionVenue; ArmyServiceInd = app.ArmyServiceInd ?? false; ArmyServiceYrOfServ = app.ArmyServiceYrOfServ; ArmyServiceResignRemark = app.ArmyServiceResignRemark; SelectionTD = app.SelectionTD; SelectionTL = app.SelectionTL; SelectionTU = app.SelectionTU; ComputerMSWord = app.ComputerMSWord; ComputerMSExcel = app.ComputerMSExcel; ComputerMSPwrPoint = app.ComputerMSPwrPoint; ComputerICT = app.ComputerICT; ComputerOthers = app.ComputerOthers; CrimeInvolvement = app.CrimeInvolvement; DrugCaseInvolvement = app.DrugCaseInvolvement; CreatedBy = app.CreatedBy; LastModifiedBy = app.LastModifiedBy; CreatedDateTime = app.CreatedDt; LastModifiedDatetTime = app.LastModifiedDt; BirthDate = app.BirthDt; EmployeeAggreeInd = app.EmployeeAggreeInd ?? false; CronicIlnessInd = app.CronicIlnessInd; ScholarshipContractStDate = app.ScholarshipContractStDate; OriginalPelepasanDocument = app.OriginalPelepasanDocument; PelepasanDocument = app.PelepasanDocument; ArmySelectionDt = app.ArmySelectionDt; MomNotApplicable = app.MomNotApplicable ?? false; DadNotApplicable = app.DadNotApplicable ?? false; GuardianNotApplicable = app.GuardianNotApplicable ?? false; if (!string.IsNullOrWhiteSpace(NewIcNo)) { var lastid = NewIcNo.Substring(NewIcNo.Length - 1); var checkgend = 0; int.TryParse(lastid, out checkgend); var even = new List<int>() { 0, 2, 4, 6, 8 }; var odd = new List<int>() { 1, 3, 5, 7, 9 }; if (string.IsNullOrWhiteSpace(app.GenderCd)) { if (even.Contains(checkgend)) GenderCd = "P"; if (odd.Contains(checkgend)) GenderCd = "L"; } } if (string.IsNullOrWhiteSpace(app.NationalityCd)) NationalityCd = "MYS"; if (string.IsNullOrWhiteSpace(app.DadNationalityCd)) DadNationalityCd = "MYS"; if (string.IsNullOrWhiteSpace(app.MomNationalityCd)) MomNationalityCd = "MYS"; if (string.IsNullOrWhiteSpace(app.GuardianNationalityCd)) GuardianNationalityCd = "MYS"; if (string.IsNullOrWhiteSpace(BirthCountryCd)) BirthCountryCd = "MYS"; if (string.IsNullOrWhiteSpace(app.CorresponAddrCountryCd)) CorresponAddrCountryCd = "MYS"; if (string.IsNullOrWhiteSpace(BirthStateCd)) { if (!string.IsNullOrWhiteSpace(NewIcNo)) { NewIcNo = NewIcNo.Trim(); if (NewIcNo.Length == 12) { var icbirthstatecode = NewIcNo.Substring(6, 2); var birthstatecode = ObjectBuilder.GetObject<IReferencePersistence>("ReferencePersistence").GetStatesByBirthStateCode(icbirthstatecode); if (null != birthstatecode) BirthStateCd = birthstatecode.StateCd; } } } if (!string.IsNullOrWhiteSpace(NewIcNo)) { var yearstr = NewIcNo.Substring(0, 2); var monthstr = NewIcNo.Substring(2, 2); var daystr = NewIcNo.Substring(4, 2); var yearint = Convert.ToInt32(yearstr); if (yearint == 0) yearint = 2000; if (yearint < 10) yearint = 2000 + yearint; if (yearint > 10) yearint = 1900 + yearint; var bdate = new DateTime(yearint, Convert.ToInt16(monthstr), Convert.ToInt16(daystr)); BirthDate = bdate; DateTime zeroTime = DateTime.Now; var daterange = DateTime.Now - bdate; int years = (zeroTime + daterange).Year - 1; DateTime today = DateTime.Today; int months = zeroTime.Month - bdate.Month; Age = zeroTime.Year - bdate.Year; Month = months; } if (ApplicantId != 0) { // get educations var education = ObjectBuilder.GetObject<IApplicantPersistence>("ApplicantPersistence").GetEducation(ApplicantId); if (null != education && education.Any()) { ApplicantEducations.Clear(); ApplicantEducations.AddRange(education.ToList()); } // get skills var skills = ObjectBuilder.GetObject<IApplicantPersistence>("ApplicantPersistence").GetSkill(ApplicantId); if (null != skills && skills.Any()) { Skills.AddRange(skills.ToList()); if (Skills.Count <= 2) Skills.Add(new ApplicantSkill() { SkillCd = "", SkillCatCd = "L", Skill = "" }); } // get sports var sports = ObjectBuilder.GetObject<IApplicantPersistence>("ApplicantPersistence").GetSport(ApplicantId); if (null != sports && sports.Any()) { Sports.AddRange(sports.Where(a => a.SportAndAssociation != null && a.SportAndAssociation.SportAssociatType == "S").ToList().DistinctBy(a => a.SportAssocId)); Kokos.AddRange(sports.Where(a => a.SportAndAssociation != null && a.SportAndAssociation.SportAssociatType == "A").ToList().DistinctBy(a => a.SportAssocId)); Others.AddRange(sports.Where(a => !string.IsNullOrWhiteSpace(a.Others))); } } if (!string.IsNullOrWhiteSpace(app.ComputerOthers)) ComputerOthersInd = true; if (acquisitionid != 0) { var acq = ObjectBuilder.GetObject<IAcquisitionPersistence>("AcquisitionPersistence").GetAcquisition(acquisitionid); if (acq != null && acq.AcquisitionTypeCd != 0) { var selectededucation = new string[] { }; var refrepos = new ReferenceRepo(); //var acqtype = ObjectBuilder.GetObject<IReferencePersistence>("ReferencePersistence").GetAcquisitionType(acq.AcquisitionTypeCd); if (null != acq.AcquisitionType) { // pegawai if (acq.AcquisitionType.ServiceCd == "10") selectededucation = new string[] { "14", "13", "25", "11", "08", "20" }; // td if (acq.AcquisitionType.ServiceCd == "01") selectededucation = new string[] { "14", "13", "25", "26", "11" }; // tl if (acq.AcquisitionType.ServiceCd == "02") selectededucation = new string[] { "14", "13", "25", "15", "26", "11" }; // tu if (acq.AcquisitionType.ServiceCd == "03") selectededucation = new string[] { "14", "13", "25", "26", "08", "11" }; var he = refrepos.GetHighEduLevels().Where(a => selectededucation.Contains(a.HighEduLevelCd)); if (he.Any()) { he = he.OrderBy(a => a.IndexNo); if (ApplicantEducations != null && ApplicantEducations.Any()) { var ledu = new List<ApplicantEducation>(); ledu.AddRange(ApplicantEducations); foreach (var ed in ledu.ToList()) { if (ed.HighEduLevelCd == "14") { var selectedsubject = ed.ApplicantEduSubjectCollection.ToList().RemoveAll(a => !string.IsNullOrEmpty(a.GradeCd)); var subjects = refrepos.GetSubjects(ed.HighEduLevelCd); if (subjects.Any()) { foreach (var s in subjects.Take(10)) { // check already exist or not in subjects if (ed.ApplicantEduId != 0) { var subbs = ObjectBuilder.GetObject<IApplicantPersistence>("ApplicantPersistence").GetSubject(ed.ApplicantEduId, s.SubjectCd); if (null != subbs) { if (ed.ApplicantEduSubjectCollection.All(a => a.SubjectCd != subbs.SubjectCd)) ed.ApplicantEduSubjectCollection.Add(new ApplicantEduSubject() { SubjectCd = subbs.SubjectCd, Subject = subbs.Subject }); } else { if (!ed.ApplicantEduSubjectCollection.Any(a => subbs != null && a.SubjectCd == subbs.SubjectCd)) ed.ApplicantEduSubjectCollection.Add(new ApplicantEduSubject() { SubjectCd = s.SubjectCd, Subject = s.SubjectDescription }); } } else { if (ed.ApplicantEduSubjectCollection.All(a => a.SubjectCd != s.SubjectCd)) ed.ApplicantEduSubjectCollection.Add(new ApplicantEduSubject() { SubjectCd = s.SubjectCd, Subject = s.SubjectDescription }); } } } var totalsubject = 16 - ed.ApplicantEduSubjectCollection.Count(); for (int i = 0; i < totalsubject; i++) { ed.ApplicantEduSubjectCollection.Add(new ApplicantEduSubject()); } } foreach (var h in he) { if (ledu.All(a => a.HighEduLevelCd != h.HighEduLevelCd)) { var edu = new ApplicantEducation() { HighEduLevelCd = h.HighEduLevelCd, HighEduLevel = h.HighestEduLevel }; if (h.HighEduLevelCd == "14") { var subjects = refrepos.GetSubjects(h.HighEduLevelCd); if (subjects.Any()) foreach (var s in subjects.Take(10)) edu.ApplicantEduSubjectCollection.Add(new ApplicantEduSubject() { SubjectCd = s.SubjectCd, Subject = s.SubjectDescription }); var totalsubject = 16 - ed.ApplicantEduSubjectCollection.Count(); for (int i = 0; i < totalsubject; i++) { edu.ApplicantEduSubjectCollection.Add(new ApplicantEduSubject()); } } ledu.Add(edu); } } } ApplicantEducations.Clear(); ApplicantEducations.AddRange(ledu.DistinctBy(a => a.HighEduLevelCd)); } else { foreach (var h in he) { var edu = new ApplicantEducation() { HighEduLevelCd = h.HighEduLevelCd, HighEduLevel = h.HighestEduLevel }; if (h.HighEduLevelCd == "14") { var subjects = refrepos.GetSubjects(h.HighEduLevelCd); if (subjects.Any()) foreach (var s in subjects.Take(10)) edu.ApplicantEduSubjectCollection.Add(new ApplicantEduSubject() { SubjectCd = s.SubjectCd, Subject = s.SubjectDescription }); for (int i = 0; i < 6; i++) { edu.ApplicantEduSubjectCollection.Add(new ApplicantEduSubject()); } } ApplicantEducations.Add(edu); } } } var scount = 0; var kcount = 0; if (Sports != null) { scount = Sports.Count(); if (scount == 0) scount = 2; else if (scount == 1) scount = 1; else scount = 0; for (int i = 0; i < scount; i++) { Sports.Add(new ApplicantSport()); } kcount = Kokos.Count(); if (kcount == 0) kcount = 2; else if (kcount == 1) kcount = 1; else kcount = 0; for (int i = 0; i < kcount; i++) { Kokos.Add(new ApplicantSport()); } } var skills = ObjectBuilder.GetObject<IReferencePersistence>("ReferencePersistence").GetSkills("L"); if (skills != null && skills.Any()) { skills = skills.Take(2); foreach (var s in skills) { if (!Skills.Any(a => a.SkillCd.Trim() == s.SkillCd.Trim())) Skills.Add(new ApplicantSkill() { SkillCd = s.SkillCd.Trim(), SkillCatCd = "L", Skill = s.SkillDescription.Trim() }); } if (Skills.Count <= 2) Skills.Add(new ApplicantSkill() { SkillCd = "", SkillCatCd = "L", Skill = "" }); } if (Others.Count() == 0) { for (int i = 0; i < 2; i++) { Others.Add(new ApplicantSport()); } } else if (Others.Count() == 1) { Others.Add(new ApplicantSport()); } } } } }