public ActionResult SubmitApplication(int acquisitionid) { var login = ObjectBuilder.GetObject<ILoginUserPersistance>("LoginUserPersistance").GetByUserName(User.Identity.Name); if (null != login) { if (login.ApplicantId.HasValue) { var applicant = ObjectBuilder.GetObject<IApplicantPersistence>("ApplicantPersistence").GetApplicant(login.ApplicantId.Value); var message = string.Empty; // check the criteria if (!AtmHelper.ValidateHeightWeightBmi(Convert.ToDouble(applicant.Height), Convert.ToDouble(applicant.Weight), acquisitionid, applicant.GenderCd, out message)) return Json(new { OK = false, message = "Permohonan anda tidak berjaya dihantar." + message }); if (acquisitionid != 0) { // check based on acquisition var acq = ObjectBuilder.GetObject<IAcquisitionPersistence>("AcquisitionPersistence").GetAcquisition(acquisitionid); if (null != acq) { var acqtype = ObjectBuilder.GetObject<IReferencePersistence>("ReferencePersistence").GetAcquisitionType(acq.AcquisitionTypeCd.Value); if (acqtype != null) { // perempuan if (acq.AcquisitionTypeCd == 3) if (applicant.GenderCd == "L") return Json(new { OK = false, message = "Permohonan anda tidak berjaya dihantar kerana pengambilan ini untuk " + acqtype.AcquisitionTypeNm }); // lelaki if (acq.AcquisitionTypeCd == 2) if (applicant.GenderCd == "P") return Json(new { OK = false, message = "Permohonan anda tidak berjaya dihantar kerana pengambilan ini untuk " + acqtype.AcquisitionTypeNm }); // Pegawai.. Check the selection indicator if (acqtype.ServiceCd == "10") { if (!applicant.SelectionTD.HasValue && !applicant.SelectionTL.HasValue && !applicant.SelectionTU.HasValue) return Json(new { OK = false, message = "Permohonan anda tidak berjaya dihantar. Sila pilih Keutamaan Perkhidmatan Pilihan" }); } } } // mandatory checking on profile photo var photo = ObjectBuilder.GetObject<IApplicantPersistence>("ApplicantPersistence").GetPhoto(applicant.ApplicantId); if (photo == null) return Json(new { OK = false, message = "Permohonan anda tidak berjaya dihantar. Sila muat naik gambar peribadi berukuran pasport (saiz tidak melebihi 500KB)." }); if (photo.Photo == null && string.IsNullOrWhiteSpace(photo.PhotoExt)) return Json(new { OK = false, message = "Permohonan anda tidak berjaya dihantar. Sila muat naik gambar peribadi berukuran pasport (saiz tidak melebihi 500KB)." }); // mandatory checking on basic information var peribadipoint = 0.0m; var edupoint = 0.0m; var spopoint = 0.0m; var saspoint = 0.0m; var chpoint = 0.0m; AtmHelper.Checklist(applicant.ApplicantId, acquisitionid, out peribadipoint, out edupoint, out spopoint, out saspoint, out chpoint); if (peribadipoint != 100m) return Json(new { OK = false, message = "Permohonan anda tidak berjaya dihantar. Maklumat peribadi tidak lengkap." }); if (edupoint != 100m) return Json(new { OK = false, message = "Permohonan anda tidak berjaya dihantar. Maklumat akademik tidak lengkap." }); if (chpoint != 100m) return Json(new { OK = false, message = "Permohonan anda tidak berjaya dihantar. Maklumat pengakuan tidak lengkap." }); // copy applicant to applicant submitted var app = new ApplicantSubmitted() { AcquisitionId = acquisitionid, Height = applicant.Height, Weight = applicant.Weight, FullName = applicant.FullName, BMI = applicant.BMI, BirthCertNo = applicant.BirthCertNo, BirthCityCd = applicant.BirthCityCd, BirthCountryCd = applicant.BirthCountryCd, BirthPlace = applicant.BirthPlace, BirthStateCd = applicant.BirthStateCd, BirthDt = applicant.BirthDt.HasValue ? applicant.BirthDt.Value : applicant.BirthDt, CreatedBy = User.Identity.Name, CreatedDt = DateTime.Now, CorresponAddr1 = applicant.CorresponAddr1, CorresponAddr2 = applicant.CorresponAddr2, CorresponAddr3 = applicant.CorresponAddr3, CorresponAddrCityCd = applicant.CorresponAddrCityCd, CorresponAddrCountryCd = applicant.CorresponAddrCountryCd, CorresponAddrPostCd = applicant.CorresponAddrPostCd, CorresponAddrStateCd = applicant.CorresponAddrStateCd, GenderCd = applicant.GenderCd, NationalityCd = applicant.NationalityCd, NationalityCertNo = applicant.NationalityCertNo, MobilePhoneNo = applicant.MobilePhoneNo, HomePhoneNo = applicant.HomePhoneNo, DadNationalityCd = applicant.DadNationalityCd, DadName = applicant.DadName, DadICNo = applicant.DadICNo, DadOccupation = applicant.DadOccupation, DadPhoneNo = applicant.DadPhoneNo, DadSalary = applicant.DadSalary, MomName = applicant.MomName, MomNationalityCd = applicant.NationalityCd, MomICNo = applicant.MomICNo, MomOccupation = applicant.MomOccupation, MomSalary = applicant.MomSalary, MomPhoneNo = applicant.MomPhoneNo, MrtlStatusCd = applicant.MrtlStatusCd, ChildNo = applicant.ChildNo, ColorBlindInd = applicant.ColorBlindInd, EthnicCd = applicant.EthnicCd, RaceCd = applicant.RaceCd, ReligionCd = applicant.ReligionCd, Email = applicant.Email, GuardianName = applicant.GuardianName, GuardianNationalityCd = applicant.GuardianNationalityCd, GuardianOccupation = applicant.GuardianOccupation, GuardianICNo = applicant.GuardianICNo, GuardianSalary = applicant.GuardianSalary, GuardianPhoneNo = applicant.GuardianPhoneNo, NewICNo = applicant.NewICNo, ScholarshipContractStDate = applicant.ScholarshipContractStDate, CurrentOccupation = applicant.CurrentOccupation, SelectionTD = applicant.SelectionTD, SelectionTL = applicant.SelectionTL, SelectionTU = applicant.SelectionTU, ArmyServiceInd = applicant.ArmyServiceInd, ArmyServiceYrOfServ = applicant.ArmyServiceYrOfServ, ArmyServiceResignRemark = applicant.ArmyServiceResignRemark, ArmySelectionInd = applicant.ArmySelectionInd, ArmySelectionDt = applicant.ArmySelectionDt, ArmySelectionVenue = applicant.ArmySelectionVenue, ComputerICT = applicant.ComputerICT, ComputerMSExcel = applicant.ComputerMSExcel, ComputerMSPwrPoint = applicant.ComputerMSPwrPoint, ComputerMSWord = applicant.ComputerMSWord, ComputerOthers = applicant.ComputerOthers, PalapesArmyNo = applicant.PalapesArmyNo, PalapesInd = applicant.PalapesInd, PalapesInstitution = applicant.PalapesInstitution, PalapesRemark = applicant.PalapesRemark, PalapesServices = applicant.PalapesServices, PalapesTauliahEndDt = applicant.PalapesTauliahEndDt, PalapesYear = applicant.PalapesYear, CurrentOrganisation = applicant.CurrentOrganisation, CurrentSalary = applicant.CurrentSalary, ScholarshipInd = applicant.ScholarshipInd, ScholarshipBody = applicant.ScholarshipBody, ScholarshipBodyAddr = applicant.ScholarshipBodyAddr, ScholarshipNoOfYrContract = applicant.ScholarshipNoOfYrContract, EmployeeAggreeInd = applicant.EmployeeAggreeInd, CronicIlnessInd = applicant.CronicIlnessInd, CrimeInvolvement = applicant.CrimeInvolvement, DrugCaseInvolvement = applicant.DrugCaseInvolvement, NoOfSibling = applicant.NoOfSibling, NoTentera = applicant.NoTentera, SpectaclesUserInd = applicant.SpectaclesUserInd, OriginalPelepasanDocument = applicant.OriginalPelepasanDocument, PelepasanDocument = applicant.PelepasanDocument, MomNotApplicable = applicant.MomNotApplicable, DadNotApplicable = applicant.DadNotApplicable, GuardianNotApplicable = applicant.GuardianNotApplicable }; var idsubmitted = app.Save(); if (idsubmitted != 0) { app.ApplicantId = idsubmitted; // get educations var education = ObjectBuilder.GetObject<IApplicantPersistence>("ApplicantPersistence").GetEducation(applicant.ApplicantId); if (null != education && education.Any()) { foreach (var edu in education) { if (!string.IsNullOrWhiteSpace(edu.OverallGrade) || edu.SKMLevel != 0 || edu.ConfermentYr != 0) { var subedu = new ApplicantEducationSubmitted { ApplicantId = app.ApplicantId, ConfermentYr = edu.ConfermentYr, EduCertTitle = edu.EduCertTitle, HighEduLevel = edu.HighEduLevel, HighEduLevelCd = edu.HighEduLevelCd, InstCd = edu.InstCd, InstitutionName = edu.InstitutionName, OverSeaInd = edu.OverSeaInd, MajorMinorCd = edu.MajorMinorCd, OverallGrade = edu.OverallGrade, SKMLevel = edu.SKMLevel, CreatedBy = User.Identity.Name, CreatedDt = DateTime.Now, }; var apeduid = subedu.Save(); foreach (var subject in edu.ApplicantEduSubjectCollection) { if (!string.IsNullOrWhiteSpace(subject.Grade) || !string.IsNullOrWhiteSpace(subject.GradeCd)) { var subsubject = new ApplicantEduSubjectSubmitted { GradeCd = !string.IsNullOrWhiteSpace(subject.GradeCd) ? subject.GradeCd.Trim() : subject.GradeCd, Grade = !string.IsNullOrWhiteSpace(subject.Grade) ? subject.Grade.Trim() : subject.Grade, ApplicantEduId = apeduid, CreatedBy = User.Identity.Name, CreatedDt = DateTime.Now, Subject = subject.Subject, SubjectCd = subject.SubjectCd, }; subsubject.Save(); } } } } } // get sports var sports = ObjectBuilder.GetObject<IApplicantPersistence>("ApplicantPersistence").GetSport(applicant.ApplicantId); if (null != sports && sports.Any()) { foreach (var sp in sports) { if ((sp.SportAssocId.HasValue && sp.SportAssocId != 0) || !string.IsNullOrWhiteSpace(sp.Others)) { var ssp = new ApplicantSportSubmitted { ApplicantId = app.ApplicantId, CreatedBy = User.Identity.Name, CreatedDt = DateTime.Now, AchievementCd = sp.AchievementCd, Year = sp.Year, Others = sp.Others, SportAssocId = sp.SportAssocId, }; ssp.Save(); } } } // get skills var skills = ObjectBuilder.GetObject<IApplicantPersistence>("ApplicantPersistence").GetSkill(applicant.ApplicantId); if (null != skills && skills.Any()) { foreach (var sp in skills) { var ssp = new ApplicantSkillSubmitted { ApplicantId = app.ApplicantId, CreatedBy = User.Identity.Name, CreatedDt = DateTime.Now, LanguageSkillSpeak = sp.LanguageSkillSpeak, LanguageSkillWrite = sp.LanguageSkillWrite, Skill = sp.Skill, AchievementCd = sp.AchievementCd, Others = sp.Others, SkillCatCd = sp.SkillCatCd, SkillCd = sp.SkillCd, }; ssp.Save(); } } // get photo if (photo.Photo != null && !string.IsNullOrWhiteSpace(photo.PhotoExt)) { var sphoto = new ApplicantSubmittedPhoto() { Photo = photo.Photo, PhotoExt = photo.PhotoExt, ApplicantId = app.ApplicantId, CreatedBy = User.Identity.Name, CreatedDate = DateTime.Now }; sphoto.Save(); } var application = new Application() { AcquisitionId = acquisitionid, CreatedBy = User.Identity.Name, CreatedDt = DateTime.Now, ApplicantId = app.ApplicantId }; var id = application.Save(); if (id != 0) return Json(new { OK = true, message = "Permohonan anda berjaya dihantar.", id = id }); } } } return Json(new { OK = false, message = "Permohonan anda tidak berjaya dihantar kerana maklumat tidak lengkap." }); } return Json(new { OK = false, message = "Permohonan anda tidak berjaya dihantar." }); }
public ActionResult SubmitProfile(ApplicantModel applicant, int acquisitionid) { if (null != applicant) { var app = new ApplicantSubmitted() { ApplicantId = applicant.ApplicantId, AcquisitionId = acquisitionid, Height = applicant.Height, Weight = applicant.Weight, FullName = applicant.FullName, BMI = applicant.Bmi, BirthCertNo = applicant.BirthCertNo, BirthCityCd = applicant.BirthCityCd, BirthCountryCd = applicant.BirthCountryCd, BirthPlace = applicant.BirthPlace, BirthStateCd = applicant.BirthStateCd, BirthDt = applicant.BirthDate.HasValue ? applicant.BirthDate.Value : applicant.BirthDate, CreatedBy = User.Identity.Name, CreatedDt = DateTime.Now, CorresponAddr1 = applicant.CorresponAddr1, CorresponAddr2 = applicant.CorresponAddr2, CorresponAddr3 = applicant.CorresponAddr3, CorresponAddrCityCd = applicant.CorresponAddrCityCd, CorresponAddrCountryCd = applicant.CorresponAddrCountryCd, CorresponAddrPostCd = applicant.CorresponAddrPostCd, CorresponAddrStateCd = applicant.CorresponAddrStateCd, GenderCd = applicant.GenderCd, NationalityCd = applicant.NationalityCd, NationalityCertNo = applicant.NationalityCertNo, MobilePhoneNo = applicant.MobilePhoneNo, HomePhoneNo = applicant.HomePhoneNo, DadNationalityCd = applicant.DadNationalityCd, DadName = applicant.DadName, DadICNo = applicant.DadIcNo, DadOccupation = applicant.DadOccupation, DadPhoneNo = applicant.DadPhoneNo, DadSalary = applicant.DadSalary, MomName = applicant.MomName, MomNationalityCd = applicant.MomNationalityCd, MomICNo = applicant.MomIcNo, MomOccupation = applicant.MomOccupation, MomSalary = applicant.MomSalary, MomPhoneNo = applicant.MomPhoneNo, MrtlStatusCd = applicant.MrtlStatusCd, ChildNo = applicant.ChildNo, ColorBlindInd = applicant.ColorBlindInd, EthnicCd = applicant.EthnicCd, RaceCd = applicant.RaceCd, ReligionCd = applicant.ReligionCd, Email = applicant.Email, GuardianName = applicant.GuardianName, GuardianNationalityCd = applicant.GuardianNationalityCd, GuardianOccupation = applicant.GuardianOccupation, GuardianICNo = applicant.GuardianIcNo, GuardianSalary = applicant.GuardianSalary, GuardianPhoneNo = applicant.GuardianPhoneNo, NewICNo = applicant.NewIcNo, ScholarshipContractStDate = applicant.ScholarshipContractStDate, CurrentOccupation = applicant.CurrentOccupation, SelectionTD = applicant.SelectionTD, SelectionTL = applicant.SelectionTL, SelectionTU = applicant.SelectionTU, ArmyServiceInd = applicant.ArmyServiceInd, ArmyServiceYrOfServ = applicant.ArmyServiceYrOfServ, ArmyServiceResignRemark = applicant.ArmyServiceResignRemark, ArmySelectionInd = applicant.ArmySelectionInd, ArmySelectionDt = applicant.ArmySelectionDt, ArmySelectionVenue = applicant.ArmySelectionVenue, ComputerICT = applicant.ComputerICT, ComputerMSExcel = applicant.ComputerMSExcel, ComputerMSPwrPoint = applicant.ComputerMSPwrPoint, ComputerMSWord = applicant.ComputerMSWord, ComputerOthers = applicant.ComputerOthers, PalapesArmyNo = applicant.PalapesArmyNo, PalapesInd = applicant.PalapesInd, PalapesInstitution = applicant.PalapesInstitution, PalapesRemark = applicant.PalapesRemark, PalapesServices = applicant.PalapesServices, PalapesTauliahEndDt = applicant.PalapesTauliahEndDt, PalapesYear = applicant.PalapesYear, CurrentOrganisation = applicant.CurrentOrganisation, CurrentSalary = applicant.CurrentSalary, ScholarshipInd = applicant.ScholarshipInd, ScholarshipBody = applicant.ScholarshipBody, ScholarshipBodyAddr = applicant.ScholarshipBodyAddr, ScholarshipNoOfYrContract = applicant.ScholarshipNoOfYrContract, EmployeeAggreeInd = applicant.EmployeeAggreeInd, CronicIlnessInd = applicant.CronicIlnessInd, CrimeInvolvement = applicant.CrimeInvolvement, DrugCaseInvolvement = applicant.DrugCaseInvolvement, NoOfSibling = applicant.NoOfSibling, NoTentera = applicant.NoTentera, SpectaclesUserInd = applicant.SpectaclesUserInd, OriginalPelepasanDocument = applicant.OriginalPelepasanDocument, PelepasanDocument = applicant.PelepasanDocument, MomNotApplicable = applicant.MomNotApplicable, DadNotApplicable = applicant.DadNotApplicable, GuardianNotApplicable = applicant.GuardianNotApplicable }; var login = ObjectBuilder.GetObject<ILoginUserPersistance>("LoginUserPersistance").GetByUserName(User.Identity.Name); var id = app.Save(); if (id > 0) { applicant.ApplicantId = id; if (applicant.ApplicantEducationSubmitteds != null && applicant.ApplicantEducationSubmitteds.Any()) { foreach (var edu in applicant.ApplicantEducationSubmitteds) { if (!string.IsNullOrWhiteSpace(edu.OverallGrade) || (edu.SKMLevel != null && edu.SKMLevel != 0) || (edu.ConfermentYr != null && edu.ConfermentYr != 0)) { edu.ApplicantId = applicant.ApplicantId; edu.CreatedBy = User.Identity.Name; edu.CreatedDt = DateTime.Now; if (edu.HighEduLevelCd == "08" || edu.HighEduLevelCd == "20") { if (edu.OverSeaInd.HasValue && edu.OverSeaInd.Value) edu.InstCd = null; else edu.InstitutionName = null; } var apeduid = edu.Save(); foreach (var subject in edu.ApplicantEduSubjectSubmittedCollection.ToList()) { if (!string.IsNullOrWhiteSpace(subject.Grade) || !string.IsNullOrWhiteSpace(subject.GradeCd)) { subject.GradeCd = !string.IsNullOrWhiteSpace(subject.GradeCd) ? subject.GradeCd.Trim() : subject.GradeCd; subject.Grade = !string.IsNullOrWhiteSpace(subject.Grade) ? subject.Grade.Trim() : subject.Grade; subject.ApplicantEduId = apeduid; subject.CreatedBy = User.Identity.Name; subject.CreatedDt = DateTime.Now; subject.Save(); } else { edu.ApplicantEduSubjectSubmittedCollection.Remove(subject); } } } } } if (applicant.SportSubmitteds != null && applicant.SportSubmitteds.Any()) { foreach (var sp in applicant.SportSubmitteds) { if (sp.SportAssocId.HasValue && sp.SportAssocId.Value != 0 && !string.IsNullOrWhiteSpace(sp.AchievementCd)) { sp.ApplicantId = applicant.ApplicantId; sp.CreatedBy = User.Identity.Name; sp.CreatedDt = DateTime.Now; sp.Save(); } } } if (applicant.KokoSubmitteds != null && applicant.KokoSubmitteds.Any()) { foreach (var sp in applicant.KokoSubmitteds) { if (sp.SportAssocId.HasValue && sp.SportAssocId != 0) { sp.ApplicantId = applicant.ApplicantId; sp.CreatedBy = User.Identity.Name; sp.CreatedDt = DateTime.Now; sp.Save(); } } } if (applicant.OtherSubmitteds != null && applicant.OtherSubmitteds.Any()) { foreach (var sp in applicant.OtherSubmitteds) { if (!string.IsNullOrWhiteSpace(sp.Others)) { sp.SportAssocId = null; sp.ApplicantId = applicant.ApplicantId; sp.CreatedBy = User.Identity.Name; sp.CreatedDt = DateTime.Now; sp.Save(); } } } if (applicant.SkillSubmitteds != null && applicant.SkillSubmitteds.Any()) { foreach (var sp in applicant.SkillSubmitteds) { if (!string.IsNullOrWhiteSpace(sp.Skill) || !string.IsNullOrWhiteSpace(sp.SkillCd)) { sp.ApplicantId = applicant.ApplicantId; sp.CreatedBy = User.Identity.Name; sp.CreatedDt = DateTime.Now; sp.Save(); } } } if (app.ApplicantId != 0) { app.LastModifiedBy = User.Identity.Name; app.LastModifiedDt = DateTime.Now; app.Save(); } var appupdated = ObjectBuilder.GetObject<IApplicantSubmittedPersistence>("ApplicantSubmittedPersistence").GetApplicant(id, acquisitionid); return Json(new { OK = true, message = "Berjaya", id, item = JsonConvert.SerializeObject(new ApplicantModel(appupdated, acquisitionid), Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }) }); } } return Json(new { OK = false, message = "Tidak Berjaya" }); }
private static tblApplicantSubmited BindindToTable(ApplicantSubmitted appl) { var usr = new tblApplicantSubmited { AcquisitionId = appl.AcquisitionId, Email = appl.Email, FullName = appl.FullName, CreatedDt = appl.CreatedDt, ArmySelectionDt = appl.ArmySelectionDt, ArmySelectionInd = appl.ArmySelectionInd, ArmySelectionVenue = appl.ArmySelectionVenue, ArmyServiceInd = appl.ArmyServiceInd, ArmyServiceResignRemark = appl.ArmyServiceResignRemark, ArmyServiceYrOfServ = appl.ArmyServiceYrOfServ, BMI = appl.BMI, BirthCertNo = appl.BirthCertNo, BirthCityCd = appl.BirthCityCd, BirthCountryCd = appl.BirthCountryCd, BirthDt = appl.BirthDt.Value, BirthPlace = appl.BirthPlace, BirthStateCd = appl.BirthStateCd, BloodTypeCd = appl.BloodTypeCd, ChildNo = appl.ChildNo, ColorBlindInd = appl.ColorBlindInd, ComputerICT = appl.ComputerICT, ComputerMSExcel = appl.ComputerMSExcel, ComputerMSPwrPoint = appl.ComputerMSPwrPoint, ComputerMSWord = appl.ComputerMSWord, ComputerOthers = appl.ComputerOthers, CorresponAddr1 = appl.CorresponAddr1, CorresponAddr2 = appl.CorresponAddr2, CorresponAddr3 = appl.CorresponAddr3, CorresponAddrCityCd = appl.CorresponAddrCityCd, CorresponAddrCountryCd = appl.CorresponAddrCountryCd, CorresponAddrPostCd = appl.CorresponAddrPostCd, CorresponAddrStateCd = appl.CorresponAddrStateCd, CreatedBy = appl.CreatedBy, CrimeInvolvement = appl.CrimeInvolvement, CronicIlnessInd = appl.CronicIlnessInd, CurrentOccupation = appl.CurrentOccupation, CurrentOrganisation = appl.CurrentOrganisation, CurrentSalary = appl.CurrentSalary, DadICNo = appl.DadICNo, DadName = appl.DadName, DadNationalityCd = appl.DadNationalityCd, DadNotApplicable = appl.DadNotApplicable, DadNotApplicableInd = appl.DadNotApplicable, DadOccupation = appl.DadOccupation, DadPhoneNo = appl.DadPhoneNo, DadSalary = appl.DadSalary, DrugCaseInvolvement = appl.DrugCaseInvolvement, EmployeeAggreeInd = appl.EmployeeAggreeInd, EthnicCd = appl.EthnicCd, FamilyHighestEduLevel = appl.FamilyHighestEduLevel, GenderCd = appl.GenderCd, GuardianICNo = appl.GuardianICNo, GuardianName = appl.GuardianName, GuardianNationalityCd = appl.GuardianNationalityCd, GuardianNotApplicable = appl.GuardianNotApplicable, GuardianNotApplicableInd = appl.GuardianNotApplicable, GuardianOccupation = appl.GuardianOccupation, GuardianPhoneNo = appl.GuardianPhoneNo, GuardianSalary = appl.GuardianSalary, Height = appl.Height, HomePhoneNo = appl.HomePhoneNo, LastModifiedBy = appl.LastModifiedBy, LastModifiedDt = appl.LastModifiedDt, MobilePhoneNo = appl.MobilePhoneNo, MomICNo = appl.MomICNo, MomName = appl.MomName, MomNationalityCd = appl.MomNationalityCd, MomNotApplicable = appl.MomNotApplicable, MomNotApplicableInd = appl.MomNotApplicable, MomOccupation = appl.MomOccupation, MomPhoneNo = appl.MomPhoneNo, MomSalary = appl.MomSalary, MrtlStatusCd = appl.MrtlStatusCd, NationalityCd = appl.NationalityCd, NationalityCertNo = appl.NationalityCertNo, NewICNo = appl.NewICNo, NoOfSibling = appl.NoOfSibling, NoTentera = appl.NoTentera, OriginalPelepasanDocument = appl.OriginalPelepasanDocument, PalapesArmyNo = appl.PalapesArmyNo, PalapesInd = appl.PalapesInd, PalapesInstitution = appl.PalapesInstitution, PalapesRemark = appl.PalapesRemark, PalapesServices = appl.PalapesServices, PalapesTauliahEndDt = appl.PalapesTauliahEndDt, PalapesYear = appl.PalapesYear, PelepasanDocument = appl.PelepasanDocument, RaceCd = appl.RaceCd, ReligionCd = appl.ReligionCd, ResidenceTypeInd = appl.ResidenceTypeInd, ScholarshipBody = appl.ScholarshipBody, ScholarshipBodyAddr = appl.ScholarshipBodyAddr, ScholarshipContractStDate = appl.ScholarshipContractStDate, ScholarshipInd = appl.ScholarshipInd, ScholarshipNoOfYrContract = appl.ScholarshipNoOfYrContract, SelectionTD = appl.SelectionTD, SelectionTL = appl.SelectionTL, SelectionTU = appl.SelectionTU, SpectaclesUserInd = appl.SpectaclesUserInd, Weight = appl.Weight }; return usr; }
public int Update(ApplicantSubmitted appl) { using (var entities = new atmEntities()) { var exist = (from a in entities.tblApplicantSubmiteds where a.ApplicantId == appl.ApplicantId select a).SingleOrDefault(); if (null != exist) { exist.AcquisitionId = appl.AcquisitionId; exist.Email = appl.Email; exist.FullName = appl.FullName; exist.ArmySelectionDt = appl.ArmySelectionDt; exist.ArmySelectionInd = appl.ArmySelectionInd; exist.ArmySelectionVenue = appl.ArmySelectionVenue; exist.ArmyServiceInd = appl.ArmyServiceInd; exist.ArmyServiceResignRemark = appl.ArmyServiceResignRemark; exist.ArmyServiceYrOfServ = appl.ArmyServiceYrOfServ; exist.BMI = appl.BMI; exist.BirthCertNo = appl.BirthCertNo; exist.BirthCityCd = appl.BirthCityCd; exist.BirthCountryCd = appl.BirthCountryCd; exist.BirthDt = appl.BirthDt.Value; exist.BirthPlace = appl.BirthPlace; exist.BirthStateCd = appl.BirthStateCd; exist.BloodTypeCd = appl.BloodTypeCd; exist.ChildNo = appl.ChildNo; exist.ColorBlindInd = appl.ColorBlindInd; exist.ComputerICT = appl.ComputerICT; exist.ComputerMSExcel = appl.ComputerMSExcel; exist.ComputerMSPwrPoint = appl.ComputerMSPwrPoint; exist.ComputerMSWord = appl.ComputerMSWord; exist.ComputerOthers = appl.ComputerOthers; exist.CorresponAddr1 = appl.CorresponAddr1; exist.CorresponAddr2 = appl.CorresponAddr2; exist.CorresponAddr3 = appl.CorresponAddr3; exist.CorresponAddrCityCd = appl.CorresponAddrCityCd; exist.CorresponAddrCountryCd = appl.CorresponAddrCountryCd; exist.CorresponAddrPostCd = appl.CorresponAddrPostCd; exist.CorresponAddrStateCd = appl.CorresponAddrStateCd; exist.CrimeInvolvement = appl.CrimeInvolvement; exist.CronicIlnessInd = appl.CronicIlnessInd; exist.CurrentOccupation = appl.CurrentOccupation; exist.CurrentOrganisation = appl.CurrentOrganisation; exist.CurrentSalary = appl.CurrentSalary; exist.DadICNo = appl.DadICNo; exist.DadName = appl.DadName; exist.DadNationalityCd = appl.DadNationalityCd; exist.DadNotApplicable = appl.DadNotApplicable; exist.DadNotApplicableInd = appl.DadNotApplicable; exist.DadOccupation = appl.DadOccupation; exist.DadPhoneNo = appl.DadPhoneNo; exist.DadSalary = appl.DadSalary; exist.DrugCaseInvolvement = appl.DrugCaseInvolvement; exist.EmployeeAggreeInd = appl.EmployeeAggreeInd; exist.EthnicCd = appl.EthnicCd; exist.FamilyHighestEduLevel = appl.FamilyHighestEduLevel; exist.GenderCd = appl.GenderCd; exist.GuardianICNo = appl.GuardianICNo; exist.GuardianName = appl.GuardianName; exist.GuardianNationalityCd = appl.GuardianNationalityCd; exist.GuardianNotApplicable = appl.GuardianNotApplicable; exist.GuardianNotApplicableInd = appl.GuardianNotApplicable; exist.GuardianOccupation = appl.GuardianOccupation; exist.GuardianPhoneNo = appl.GuardianPhoneNo; exist.GuardianSalary = appl.GuardianSalary; exist.Height = appl.Height; exist.HomePhoneNo = appl.HomePhoneNo; exist.LastModifiedBy = appl.LastModifiedBy; exist.LastModifiedDt = appl.LastModifiedDt; exist.MobilePhoneNo = appl.MobilePhoneNo; exist.MomICNo = appl.MomICNo; exist.MomName = appl.MomName; exist.MomNationalityCd = appl.MomNationalityCd; exist.MomNotApplicable = appl.MomNotApplicable; exist.MomNotApplicableInd = appl.MomNotApplicable; exist.MomOccupation = appl.MomOccupation; exist.MomPhoneNo = appl.MomPhoneNo; exist.MomSalary = appl.MomSalary; exist.MrtlStatusCd = appl.MrtlStatusCd; exist.NationalityCd = appl.NationalityCd; exist.NationalityCertNo = appl.NationalityCertNo; exist.NewICNo = appl.NewICNo; exist.NoOfSibling = appl.NoOfSibling; exist.NoTentera = appl.NoTentera; exist.OriginalPelepasanDocument = appl.OriginalPelepasanDocument; exist.PalapesArmyNo = appl.PalapesArmyNo; exist.PalapesInd = appl.PalapesInd; exist.PalapesInstitution = appl.PalapesInstitution; exist.PalapesRemark = appl.PalapesRemark; exist.PalapesServices = appl.PalapesServices; exist.PalapesTauliahEndDt = appl.PalapesTauliahEndDt; exist.PalapesYear = appl.PalapesYear; exist.PelepasanDocument = appl.PelepasanDocument; exist.RaceCd = appl.RaceCd; exist.ReligionCd = appl.ReligionCd; exist.ResidenceTypeInd = appl.ResidenceTypeInd; exist.ScholarshipBody = appl.ScholarshipBody; exist.ScholarshipBodyAddr = appl.ScholarshipBodyAddr; exist.ScholarshipContractStDate = appl.ScholarshipContractStDate; exist.ScholarshipInd = appl.ScholarshipInd; exist.ScholarshipNoOfYrContract = appl.ScholarshipNoOfYrContract; exist.SelectionTD = appl.SelectionTD; exist.SelectionTL = appl.SelectionTL; exist.SelectionTU = appl.SelectionTU; exist.SpectaclesUserInd = appl.SpectaclesUserInd; exist.Weight = appl.Weight; entities.SaveChanges(); return exist.ApplicantId; } } return 0; }
public int Save(ApplicantSubmitted appl) { using (var entities = new atmEntities()) { var exist = (from a in entities.tblApplicantSubmiteds where a.NewICNo == appl.NewICNo && a.AcquisitionId == appl.AcquisitionId select a).OrderByDescending(a => a.CreatedDt).FirstOrDefault(); if (null != exist) { appl.ApplicantId = exist.ApplicantId; return Update(appl); } var usr = BindindToTable(appl); entities.tblApplicantSubmiteds.Add(usr); if (entities.SaveChanges() > 0) return usr.ApplicantId; } return 0; }
private static ApplicantSubmitted BindingToClass(tblApplicantSubmited appl) { var usr = new ApplicantSubmitted(); usr.ApplicantId = appl.ApplicantId; usr.AcquisitionId = appl.AcquisitionId; usr.Email = appl.Email; usr.FullName = appl.FullName; usr.CreatedDt = appl.CreatedDt; usr.ArmySelectionDt = appl.ArmySelectionDt; usr.ArmySelectionInd = appl.ArmySelectionInd; usr.ArmySelectionVenue = appl.ArmySelectionVenue; usr.ArmyServiceInd = appl.ArmyServiceInd; usr.ArmyServiceResignRemark = appl.ArmyServiceResignRemark; usr.ArmyServiceYrOfServ = appl.ArmyServiceYrOfServ; usr.BMI = appl.BMI; usr.BirthCertNo = appl.BirthCertNo; usr.BirthCityCd = appl.BirthCityCd; usr.BirthCountryCd = appl.BirthCountryCd; usr.BirthDt = appl.BirthDt; usr.BirthPlace = appl.BirthPlace; usr.BirthStateCd = appl.BirthStateCd; usr.BirthStateName = appl.tblREFState != null ? appl.tblREFState.State : string.Empty; usr.BloodTypeCd = appl.BloodTypeCd; usr.ChildNo = appl.ChildNo; usr.ColorBlindInd = appl.ColorBlindInd; usr.ComputerICT = appl.ComputerICT; usr.ComputerMSExcel = appl.ComputerMSExcel; usr.ComputerMSPwrPoint = appl.ComputerMSPwrPoint; usr.ComputerMSWord = appl.ComputerMSWord; usr.ComputerOthers = appl.ComputerOthers; usr.CorresponAddr1 = appl.CorresponAddr1; usr.CorresponAddr2 = appl.CorresponAddr2; usr.CorresponAddr3 = appl.CorresponAddr3; usr.CorresponAddrCityCd = appl.CorresponAddrCityCd; usr.CorresponAddrCountryCd = appl.CorresponAddrCountryCd; usr.CorresponAddrPostCd = appl.CorresponAddrPostCd; usr.CorresponAddrStateCd = appl.CorresponAddrStateCd; usr.CreatedBy = appl.CreatedBy; usr.CrimeInvolvement = appl.CrimeInvolvement; usr.CronicIlnessInd = appl.CronicIlnessInd; usr.CurrentOccupation = appl.CurrentOccupation; usr.CurrentOrganisation = appl.CurrentOrganisation; usr.CurrentSalary = appl.CurrentSalary; usr.DadICNo = appl.DadICNo; usr.DadName = appl.DadName; usr.DadNationalityCd = appl.DadNationalityCd; usr.DadNotApplicable = appl.DadNotApplicable; usr.DadOccupation = appl.DadOccupation; usr.DadPhoneNo = appl.DadPhoneNo; usr.DadSalary = appl.DadSalary; usr.DrugCaseInvolvement = appl.DrugCaseInvolvement; usr.EmployeeAggreeInd = appl.EmployeeAggreeInd; usr.EthnicCd = appl.EthnicCd; usr.FamilyHighestEduLevel = appl.FamilyHighestEduLevel; usr.GenderCd = appl.GenderCd; usr.GuardianICNo = appl.GuardianICNo; usr.GuardianName = appl.GuardianName; usr.GuardianNationalityCd = appl.GuardianNationalityCd; usr.GuardianNotApplicable = appl.GuardianNotApplicable; usr.GuardianOccupation = appl.GuardianOccupation; usr.GuardianPhoneNo = appl.GuardianPhoneNo; usr.GuardianSalary = appl.GuardianSalary; usr.Height = appl.Height; usr.HomePhoneNo = appl.HomePhoneNo; usr.LastModifiedBy = appl.LastModifiedBy; usr.LastModifiedDt = appl.LastModifiedDt; usr.MobilePhoneNo = appl.MobilePhoneNo; usr.MomICNo = appl.MomICNo; usr.MomName = appl.MomName; usr.MomNationalityCd = appl.MomNationalityCd; usr.MomNotApplicable = appl.MomNotApplicable; usr.MomOccupation = appl.MomOccupation; usr.MomPhoneNo = appl.MomPhoneNo; usr.MomSalary = appl.MomSalary; usr.MrtlStatusCd = appl.MrtlStatusCd; usr.NationalityCd = appl.NationalityCd; usr.NationalityCertNo = appl.NationalityCertNo; usr.NewICNo = appl.NewICNo; usr.NoOfSibling = appl.NoOfSibling; usr.NoTentera = appl.NoTentera; usr.OriginalPelepasanDocument = appl.OriginalPelepasanDocument; usr.PalapesArmyNo = appl.PalapesArmyNo; usr.PalapesInd = appl.PalapesInd; usr.PalapesInstitution = appl.PalapesInstitution; usr.PalapesRemark = appl.PalapesRemark; usr.PalapesServices = appl.PalapesServices; usr.PalapesTauliahEndDt = appl.PalapesTauliahEndDt; usr.PalapesYear = appl.PalapesYear; usr.PelepasanDocument = appl.PelepasanDocument; usr.RaceCd = appl.RaceCd; usr.ReligionCd = appl.ReligionCd; usr.ResidenceTypeInd = appl.ResidenceTypeInd; usr.ScholarshipBody = appl.ScholarshipBody; usr.ScholarshipBodyAddr = appl.ScholarshipBodyAddr; usr.ScholarshipContractStDate = appl.ScholarshipContractStDate; usr.ScholarshipInd = appl.ScholarshipInd; usr.ScholarshipNoOfYrContract = appl.ScholarshipNoOfYrContract; usr.SelectionTD = appl.SelectionTD; usr.SelectionTL = appl.SelectionTL; usr.SelectionTU = appl.SelectionTU; usr.SpectaclesUserInd = appl.SpectaclesUserInd; usr.Weight = appl.Weight; if (!string.IsNullOrWhiteSpace(appl.CorresponAddrStateCd)) { if (appl.tblREFState1 != null) usr.CorresponAddrStateNm = appl.tblREFState1.State; } if (!string.IsNullOrWhiteSpace(appl.CorresponAddrCityCd)) { if (appl.tblREFCity1 != null) usr.CorresponAddrCityNm = appl.tblREFCity1.City; } return usr; }
public ApplicantModel(ApplicantSubmitted 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; BirthDateString = string.Format("{0:dd/MM/yyyy}", 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<IApplicantSubmittedPersistence>("ApplicantSubmittedPersistence").GetEducation(ApplicantId, acquisitionid); if (null != education && education.Any()) { ApplicantEducationSubmitteds.Clear(); ApplicantEducationSubmitteds.AddRange(education.ToList()); } // get skills var skills = ObjectBuilder.GetObject<IApplicantSubmittedPersistence>("ApplicantSubmittedPersistence").GetSkill(ApplicantId, acquisitionid); if (null != skills && skills.Any()) { SkillSubmitteds.AddRange(skills.ToList()); if (SkillSubmitteds.Count <= 2) SkillSubmitteds.Add(new ApplicantSkillSubmitted() { SkillCd = "", SkillCatCd = "L", Skill = "" }); } // get sports var sports = ObjectBuilder.GetObject<IApplicantSubmittedPersistence>("ApplicantSubmittedPersistence").GetSport(ApplicantId, acquisitionid); if (null != sports && sports.Any()) { SportSubmitteds.AddRange(sports.Where(a => a.SportAndAssociation != null && a.SportAndAssociation.SportAssociatType == "S").ToList().DistinctBy(a => a.SportAssocId)); KokoSubmitteds.AddRange(sports.Where(a => a.SportAndAssociation != null && a.SportAndAssociation.SportAssociatType == "A").ToList().DistinctBy(a => a.SportAssocId)); OtherSubmitteds.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 (ApplicantEducationSubmitteds != null && ApplicantEducationSubmitteds.Any()) { var ledu = new List<ApplicantEducationSubmitted>(); ledu.AddRange(ApplicantEducationSubmitteds); foreach (var ed in ledu.ToList()) { if (ed.HighEduLevelCd == "14") { var selectedsubject = ed.ApplicantEduSubjectSubmittedCollection.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<IApplicantSubmittedPersistence>("ApplicantSubmittedPersistence").GetSubject(ed.ApplicantEduId, s.SubjectCd); if (null != subbs) { if (ed.ApplicantEduSubjectSubmittedCollection.All(a => a.SubjectCd != subbs.SubjectCd)) ed.ApplicantEduSubjectSubmittedCollection.Add(new ApplicantEduSubjectSubmitted() { SubjectCd = subbs.SubjectCd, Subject = subbs.Subject }); } else { if (!ed.ApplicantEduSubjectSubmittedCollection.Any(a => subbs != null && a.SubjectCd == subbs.SubjectCd)) ed.ApplicantEduSubjectSubmittedCollection.Add(new ApplicantEduSubjectSubmitted() { SubjectCd = s.SubjectCd, Subject = s.SubjectDescription }); } } else { if (ed.ApplicantEduSubjectSubmittedCollection.All(a => a.SubjectCd != s.SubjectCd)) ed.ApplicantEduSubjectSubmittedCollection.Add(new ApplicantEduSubjectSubmitted() { SubjectCd = s.SubjectCd, Subject = s.SubjectDescription }); } } } var totalsubject = 16 - ed.ApplicantEduSubjectSubmittedCollection.Count(); for (int i = 0; i < totalsubject; i++) { ed.ApplicantEduSubjectSubmittedCollection.Add(new ApplicantEduSubjectSubmitted()); } } foreach (var h in he) { if (ledu.All(a => a.HighEduLevelCd != h.HighEduLevelCd)) { var edu = new ApplicantEducationSubmitted() { 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.ApplicantEduSubjectSubmittedCollection.Add(new ApplicantEduSubjectSubmitted() { SubjectCd = s.SubjectCd, Subject = s.SubjectDescription }); var totalsubject = 16 - ed.ApplicantEduSubjectSubmittedCollection.Count(); for (int i = 0; i < totalsubject; i++) { edu.ApplicantEduSubjectSubmittedCollection.Add(new ApplicantEduSubjectSubmitted()); } } ledu.Add(edu); } } } ApplicantEducationSubmitteds.Clear(); ApplicantEducationSubmitteds.AddRange(ledu.DistinctBy(a => a.HighEduLevelCd)); } else { foreach (var h in he) { var edu = new ApplicantEducationSubmitted() { 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.ApplicantEduSubjectSubmittedCollection.Add(new ApplicantEduSubjectSubmitted() { SubjectCd = s.SubjectCd, Subject = s.SubjectDescription }); for (int i = 0; i < 6; i++) { edu.ApplicantEduSubjectSubmittedCollection.Add(new ApplicantEduSubjectSubmitted()); } } ApplicantEducationSubmitteds.Add(edu); } } } var scount = 0; var kcount = 0; if (SportSubmitteds != null) { scount = SportSubmitteds.Count(); if (scount == 0) scount = 2; else if (scount == 1) scount = 1; else scount = 0; for (int i = 0; i < scount; i++) { SportSubmitteds.Add(new ApplicantSportSubmitted()); } kcount = KokoSubmitteds.Count(); if (kcount == 0) kcount = 2; else if (kcount == 1) kcount = 1; else kcount = 0; for (int i = 0; i < kcount; i++) { KokoSubmitteds.Add(new ApplicantSportSubmitted()); } } var skills = ObjectBuilder.GetObject<IReferencePersistence>("ReferencePersistence").GetSkills("L"); if (skills != null && skills.Any()) { skills = skills.Take(2); foreach (var s in skills) { if (!SkillSubmitteds.Any(a => a.SkillCd.Trim() == s.SkillCd.Trim())) SkillSubmitteds.Add(new ApplicantSkillSubmitted() { SkillCd = s.SkillCd.Trim(), SkillCatCd = "L", Skill = s.SkillDescription.Trim() }); } if (SkillSubmitteds.Count <= 2) SkillSubmitteds.Add(new ApplicantSkillSubmitted() { SkillCd = "", SkillCatCd = "L", Skill = "" }); } if (!OtherSubmitteds.Any()) { for (int i = 0; i < 2; i++) { OtherSubmitteds.Add(new ApplicantSportSubmitted()); } } else if (OtherSubmitteds.Count() == 1) { OtherSubmitteds.Add(new ApplicantSportSubmitted()); } } } } }