diff --git a/Services/PeriodExamService.cs b/Services/PeriodExamService.cs index 366bcbe..a62f90f 100644 --- a/Services/PeriodExamService.cs +++ b/Services/PeriodExamService.cs @@ -1987,76 +1987,229 @@ namespace BMA.EHR.Recurit.Exam.Service.Services .OrderBy(x => x.DurationStart) .Where(x => x.Candidate.Id == item.Id) .ToListAsync(); - - _data.Add(new + if(careers.Any()) { - Num = num.ToString().ToThaiNumber(), - PositionName = item.PositionName != null && item.PositionLevelName != null ? $"{item.PositionName} {item.PositionLevelName}".ToThaiNumber() : "-", - FullName = item.FullName != null ? item.FullName.ToThaiNumber() : "-", - Nationality = item.Nationality != null ? item.Nationality.ToThaiNumber() : "-", - ReligionName = item.ReligionName != null ? item.ReligionName.ToThaiNumber() : "-", - DateOfBirth = item.DateOfBirth != null ? item.DateOfBirth.ToThaiNumber() : "-", - Age = item.Age != null ? item.Age.ToThaiNumber() : "-", - Telephone = item.Telephone != null ? item.Telephone.ToThaiNumber() : "-", - Email = item.Email != null ? item.Email : "-", - CitizenId = item.CitizenId != null ? item.CitizenId.ToThaiNumber() : "-", + var firstCareer = careers.First(); - EducationLevelExamName = education == null ? "-" : education.EducationLevelExamName.ToThaiNumber(), - EducationName = education == null ? "-" : education.EducationName.ToThaiNumber(), - EducationMajor = education == null ? "-" : education.EducationMajor.ToThaiNumber(), - EducationLocation = education == null ? "-" : education.EducationLocation.ToThaiNumber(), - EducationEndDate = education == null ? "-" : (education.EducationEndDate == null ? "-" : education.EducationEndDate.Value.Date.ToThaiShortDate().ToThaiNumber()), - EducationScores = education == null ? "-" : education.EducationScores.ToThaiNumber(), - EducationType = education == null ? "-" : education.EducationType.ToThaiNumber(), - EducationLevelHighName = education == null ? "-" : education.EducationLevelHighName.ToThaiNumber().ToThaiNumber(), + _data.Add(new + { + Num = num.ToString().ToThaiNumber(), + PositionName = item.PositionName != null && item.PositionLevelName != null ? $"{item.PositionName} {item.PositionLevelName}".ToThaiNumber() : "-", + FullName = item.FullName != null ? item.FullName.ToThaiNumber() : "-", + Nationality = item.Nationality != null ? item.Nationality.ToThaiNumber() : "-", + ReligionName = item.ReligionName != null ? item.ReligionName.ToThaiNumber() : "-", + DateOfBirth = item.DateOfBirth != null ? item.DateOfBirth.ToThaiNumber() : "-", + Age = item.Age != null ? item.Age.ToThaiNumber() : "-", + Telephone = item.Telephone != null ? item.Telephone.ToThaiNumber() : "-", + Email = item.Email != null ? item.Email : "-", + CitizenId = item.CitizenId != null ? item.CitizenId.ToThaiNumber() : "-", - OccupationPositionType = item.OccupationPositionType == null ? "-" : GenerateStatusOccupation(item.OccupationPositionType), - OccupationPosition = item.OccupationPosition == null ? "-" : item.OccupationPosition.ToThaiNumber(), - OccupationSalary = item.OccupationSalary == null ? "-" : item.OccupationSalary.ToString().ToThaiNumber(), - OccupationGroup = item.OccupationGroup == null ? "-" : item.OccupationGroup.ToThaiNumber(), - OccupationPile = item.OccupationPile == null ? "-" : item.OccupationPile.ToThaiNumber(), - OccupationOrg = item.OccupationOrg == null ? "-" : item.OccupationOrg.ToThaiNumber(), - OccupationTelephone = item.OccupationTelephone == null ? "-" : item.OccupationTelephone.ToThaiNumber(), + EducationLevelExamName = education.EducationLevelExamName == null ? "-" : education.EducationLevelExamName.ToThaiNumber(), + EducationName = education.EducationName == null ? "-" : education.EducationName.ToThaiNumber(), + EducationMajor = education.EducationMajor == null ? "-" : education.EducationMajor.ToThaiNumber(), + EducationLocation = education.EducationLocation == null ? "-" : education.EducationLocation.ToThaiNumber(), + EducationEndDate = education.EducationEndDate == null ? "-" : (education.EducationEndDate == null ? "-" : education.EducationEndDate.Value.Date.ToThaiShortDate().ToThaiNumber()), + EducationScores = education.EducationScores == null ? "-" : education.EducationScores.ToThaiNumber(), + EducationType = education.EducationType == null ? "-" : education.EducationType.ToThaiNumber(), + EducationLevelHighName = education.EducationLevelHighName == null ? "-" : education.EducationLevelHighName.ToThaiNumber(), - Position = /*career.Position == null ? "-" : career.Position.ToThaiNumber()*/"-", - Type = /*career.Type == null ? "-" : career.Type*/"-", - DurationStart = /*career.DurationStart == null ? "-" : career.DurationStart.Date.ToThaiShortDate().ToThaiNumber()*/"-", - DurationEnd = /*career.DurationEnd == null ? "-" : career.DurationEnd.Date.ToThaiShortDate().ToThaiNumber()*/"-", - RangeDate = /*career.RangeDate == null ? "-" : career.RangeDate.ToThaiNumber()*/"-", + OccupationPositionType = item.OccupationPositionType == null ? "-" : GenerateStatusOccupation(item.OccupationPositionType), + OccupationPosition = item.OccupationPosition == null ? "-" : item.OccupationPosition.ToThaiNumber(), + OccupationSalary = item.OccupationSalary == null ? "-" : item.OccupationSalary.ToString().ToThaiNumber(), + OccupationGroup = item.OccupationGroup == null ? "-" : item.OccupationGroup.ToThaiNumber(), + OccupationPile = item.OccupationPile == null ? "-" : item.OccupationPile.ToThaiNumber(), + OccupationOrg = item.OccupationOrg == null ? "-" : item.OccupationOrg.ToThaiNumber(), + OccupationTelephone = item.OccupationTelephone == null ? "-" : item.OccupationTelephone.ToThaiNumber(), - CurrentAddress = item.CurrentAddress == null ? "-" : item.CurrentAddress.ToThaiNumber(), - CurrentProvinceName = item.CurrentProvinceName == null ? "-" : item.CurrentProvinceName.ToThaiNumber(), - CurrentDistrictName = item.CurrentDistrictName == null ? "-" : item.CurrentDistrictName.ToThaiNumber(), - CurrentSubDistrictName = item.CurrentSubDistrictName == null ? "-" : item.CurrentSubDistrictName.ToThaiNumber(), - CurrentZipCode = item.CurrentZipCode == null ? "-" : item.CurrentZipCode.ToThaiNumber(), + Position = firstCareer.Position == null ? "-" : firstCareer.Position.ToThaiNumber(), + Type = firstCareer.Type == null ? "-" : firstCareer.Type, + DurationStart = firstCareer.DurationStart == null ? "-" : firstCareer.DurationStart.Date.ToThaiShortDate().ToThaiNumber(), + DurationEnd = firstCareer.DurationEnd == null ? "-" : firstCareer.DurationEnd.Date.ToThaiShortDate().ToThaiNumber(), + RangeDate = firstCareer.RangeDate == null ? "-" : firstCareer.RangeDate.ToThaiNumber(), - RegistAddress = item.RegistAddress == null ? "-" : item.RegistAddress.ToThaiNumber(), - RegistProvinceName = item.RegistProvinceName == null ? "-" : item.RegistProvinceName.ToThaiNumber(), - RegistDistrictName = item.RegistDistrictName == null ? "-" : item.RegistDistrictName.ToThaiNumber(), - RegistSubDistrictName = item.RegistSubDistrictName == null ? "-" : item.RegistSubDistrictName.ToThaiNumber(), - RegistZipCode = item.RegistZipCode == null ? "-" : item.RegistZipCode.ToThaiNumber(), + CurrentAddress = item.CurrentAddress == null ? "-" : item.CurrentAddress.ToThaiNumber(), + CurrentProvinceName = item.CurrentProvinceName == null ? "-" : item.CurrentProvinceName.ToThaiNumber(), + CurrentDistrictName = item.CurrentDistrictName == null ? "-" : item.CurrentDistrictName.ToThaiNumber(), + CurrentSubDistrictName = item.CurrentSubDistrictName == null ? "-" : item.CurrentSubDistrictName.ToThaiNumber(), + CurrentZipCode = item.CurrentZipCode == null ? "-" : item.CurrentZipCode.ToThaiNumber(), - ContactFullName = item.ContactFullName == null ? "-" : item.ContactFullName.ToThaiNumber(), - ContactRelations = item.ContactRelations == null ? "-" : item.ContactRelations.ToThaiNumber(), - ContactTel = item.ContactTel == null ? "-" : item.ContactTel.ToThaiNumber(), - CandidateStatus = GenerateStatusCandidate(item.Status), + RegistAddress = item.RegistAddress == null ? "-" : item.RegistAddress.ToThaiNumber(), + RegistProvinceName = item.RegistProvinceName == null ? "-" : item.RegistProvinceName.ToThaiNumber(), + RegistDistrictName = item.RegistDistrictName == null ? "-" : item.RegistDistrictName.ToThaiNumber(), + RegistSubDistrictName = item.RegistSubDistrictName == null ? "-" : item.RegistSubDistrictName.ToThaiNumber(), + RegistZipCode = item.RegistZipCode == null ? "-" : item.RegistZipCode.ToThaiNumber(), + + ContactFullName = item.ContactFullName == null ? "-" : item.ContactFullName.ToThaiNumber(), + ContactRelations = item.ContactRelations == null ? "-" : item.ContactRelations.ToThaiNumber(), + ContactTel = item.ContactTel == null ? "-" : item.ContactTel.ToThaiNumber(), + CandidateStatus = GenerateStatusCandidate(item.Status), + + Number = item.Number == null ? "-" : item.Number.ToThaiNumber(), + ExamIdenNumber = item.ExamIdenNumber == null ? "-" : item.ExamIdenNumber.ToThaiNumber(), + SeatNumber = item.SeatNumber == null ? "-" : item.SeatNumber.ToThaiNumber(), + PointTotalA = item.PointTotalA == null ? "-" : item.PointTotalA.ToThaiNumber(), + PointA = item.PointA == null ? "-" : item.PointA.ToThaiNumber(), + ResultA = item.ResultA == null ? "-" : item.ResultA.ToThaiNumber(), + PointTotalB = item.PointTotalB == null ? "-" : item.PointTotalB.ToThaiNumber(), + PointB = item.PointB == null ? "-" : item.PointB.ToThaiNumber(), + ResultB = item.ResultB == null ? "-" : item.ResultB.ToThaiNumber(), + PointTotalC = item.PointTotalC == null ? "-" : item.PointTotalC.ToThaiNumber(), + PointC = item.PointC == null ? "-" : item.PointC.ToThaiNumber(), + ResultC = item.ResultC == null ? "-" : item.ResultC.ToThaiNumber(), + Pass = item.Pass == null ? "-" : item.Pass.ToThaiNumber(), + CreatedAt = item.CreatedAt.Date == null ? "-" : item.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), + RegisterDate = item.RegisterDate.Value.Date == null ? "-" : $"{item.RegisterDate.Value.Date.ToThaiShortDate()} {item.RegisterDate.Value.ToString("HH:mm:ss.ffff")}".ToThaiNumber() + }); + + if (careers.Count > 1) + { + foreach (var career in careers.Skip(1)) + { + _data.Add(new + { + Num = "", + PositionName = "", + FullName = "", + Nationality = "", + ReligionName = "", + DateOfBirth = "", + Age = "", + Telephone = "", + Email = "", + CitizenId = "", + + EducationLevelExamName = "", + EducationName = "", + EducationMajor = "", + EducationLocation = "", + EducationEndDate = "", + EducationScores = "", + EducationType = "", + EducationLevelHighName = "", + + OccupationPositionType = "", + OccupationPosition = "", + OccupationSalary = "", + OccupationGroup = "", + OccupationPile = "", + OccupationOrg = "", + OccupationTelephone = "", + + Position = career.Position != null ? career.Position.ToThaiNumber() : "-", + Type = career.Type != null ? career.Type : "-", + DurationStart = career.DurationStart != null ? career.DurationStart.Date.ToThaiShortDate().ToThaiNumber() : "-", + DurationEnd = career.DurationEnd != null ? career.DurationEnd.Date.ToThaiShortDate().ToThaiNumber() : "-", + RangeDate = career.RangeDate != null ? career.RangeDate.ToThaiNumber() : "-", + + CurrentAddress = "", + CurrentProvinceName = "", + CurrentDistrictName = "", + CurrentSubDistrictName = "", + CurrentZipCode = "", + + RegistAddress = "", + RegistProvinceName = "", + RegistDistrictName = "", + RegistSubDistrictName = "", + RegistZipCode = "", + + ContactFullName = "", + ContactRelations = "", + ContactTel = "", + CandidateStatus = "", + + Number = "", + ExamIdenNumber = "", + SeatNumber = "", + PointTotalA = "", + PointA = "", + ResultA = "", + PointTotalB = "", + PointB = "", + ResultB = "", + PointTotalC = "", + PointC = "", + ResultC = "", + Pass = "", + CreatedAt = "", + RegisterDate = "" + }); + } + } + } + else + { + _data.Add(new + { + Num = num.ToString().ToThaiNumber(), + PositionName = item.PositionName != null && item.PositionLevelName != null ? $"{item.PositionName} {item.PositionLevelName}".ToThaiNumber() : "-", + FullName = item.FullName != null ? item.FullName.ToThaiNumber() : "-", + Nationality = item.Nationality != null ? item.Nationality.ToThaiNumber() : "-", + ReligionName = item.ReligionName != null ? item.ReligionName.ToThaiNumber() : "-", + DateOfBirth = item.DateOfBirth != null ? item.DateOfBirth.ToThaiNumber() : "-", + Age = item.Age != null ? item.Age.ToThaiNumber() : "-", + Telephone = item.Telephone != null ? item.Telephone.ToThaiNumber() : "-", + Email = item.Email != null ? item.Email : "-", + CitizenId = item.CitizenId != null ? item.CitizenId.ToThaiNumber() : "-", + + EducationLevelExamName = education.EducationLevelExamName == null ? "-" : education.EducationLevelExamName.ToThaiNumber(), + EducationName = education.EducationName == null ? "-" : education.EducationName.ToThaiNumber(), + EducationMajor = education.EducationMajor == null ? "-" : education.EducationMajor.ToThaiNumber(), + EducationLocation = education.EducationLocation == null ? "-" : education.EducationLocation.ToThaiNumber(), + EducationEndDate = education.EducationEndDate == null ? "-" : (education.EducationEndDate == null ? "-" : education.EducationEndDate.Value.Date.ToThaiShortDate().ToThaiNumber()), + EducationScores = education.EducationScores == null ? "-" : education.EducationScores.ToThaiNumber(), + EducationType = education.EducationType == null ? "-" : education.EducationType.ToThaiNumber(), + EducationLevelHighName = education.EducationLevelHighName == null ? "-" : education.EducationLevelHighName.ToThaiNumber(), + + OccupationPositionType = item.OccupationPositionType == null ? "-" : GenerateStatusOccupation(item.OccupationPositionType), + OccupationPosition = item.OccupationPosition == null ? "-" : item.OccupationPosition.ToThaiNumber(), + OccupationSalary = item.OccupationSalary == null ? "-" : item.OccupationSalary.ToString().ToThaiNumber(), + OccupationGroup = item.OccupationGroup == null ? "-" : item.OccupationGroup.ToThaiNumber(), + OccupationPile = item.OccupationPile == null ? "-" : item.OccupationPile.ToThaiNumber(), + OccupationOrg = item.OccupationOrg == null ? "-" : item.OccupationOrg.ToThaiNumber(), + OccupationTelephone = item.OccupationTelephone == null ? "-" : item.OccupationTelephone.ToThaiNumber(), + + Position = "-", + Type = "-", + DurationStart = "-", + DurationEnd = "-", + RangeDate = "-", + + CurrentAddress = item.CurrentAddress == null ? "-" : item.CurrentAddress.ToThaiNumber(), + CurrentProvinceName = item.CurrentProvinceName == null ? "-" : item.CurrentProvinceName.ToThaiNumber(), + CurrentDistrictName = item.CurrentDistrictName == null ? "-" : item.CurrentDistrictName.ToThaiNumber(), + CurrentSubDistrictName = item.CurrentSubDistrictName == null ? "-" : item.CurrentSubDistrictName.ToThaiNumber(), + CurrentZipCode = item.CurrentZipCode == null ? "-" : item.CurrentZipCode.ToThaiNumber(), + + RegistAddress = item.RegistAddress == null ? "-" : item.RegistAddress.ToThaiNumber(), + RegistProvinceName = item.RegistProvinceName == null ? "-" : item.RegistProvinceName.ToThaiNumber(), + RegistDistrictName = item.RegistDistrictName == null ? "-" : item.RegistDistrictName.ToThaiNumber(), + RegistSubDistrictName = item.RegistSubDistrictName == null ? "-" : item.RegistSubDistrictName.ToThaiNumber(), + RegistZipCode = item.RegistZipCode == null ? "-" : item.RegistZipCode.ToThaiNumber(), + + ContactFullName = item.ContactFullName == null ? "-" : item.ContactFullName.ToThaiNumber(), + ContactRelations = item.ContactRelations == null ? "-" : item.ContactRelations.ToThaiNumber(), + ContactTel = item.ContactTel == null ? "-" : item.ContactTel.ToThaiNumber(), + CandidateStatus = GenerateStatusCandidate(item.Status), + + Number = item.Number == null ? "-" : item.Number.ToThaiNumber(), + ExamIdenNumber = item.ExamIdenNumber == null ? "-" : item.ExamIdenNumber.ToThaiNumber(), + SeatNumber = item.SeatNumber == null ? "-" : item.SeatNumber.ToThaiNumber(), + PointTotalA = item.PointTotalA == null ? "-" : item.PointTotalA.ToThaiNumber(), + PointA = item.PointA == null ? "-" : item.PointA.ToThaiNumber(), + ResultA = item.ResultA == null ? "-" : item.ResultA.ToThaiNumber(), + PointTotalB = item.PointTotalB == null ? "-" : item.PointTotalB.ToThaiNumber(), + PointB = item.PointB == null ? "-" : item.PointB.ToThaiNumber(), + ResultB = item.ResultB == null ? "-" : item.ResultB.ToThaiNumber(), + PointTotalC = item.PointTotalC == null ? "-" : item.PointTotalC.ToThaiNumber(), + PointC = item.PointC == null ? "-" : item.PointC.ToThaiNumber(), + ResultC = item.ResultC == null ? "-" : item.ResultC.ToThaiNumber(), + Pass = item.Pass == null ? "-" : item.Pass.ToThaiNumber(), + CreatedAt = item.CreatedAt.Date == null ? "-" : item.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), + RegisterDate = item.RegisterDate.Value.Date == null ? "-" : $"{item.RegisterDate.Value.Date.ToThaiShortDate()} {item.RegisterDate.Value.ToString("HH:mm:ss.ffff")}".ToThaiNumber() + }); + } - Number = item.Number == null ? "-" : item.Number.ToThaiNumber(), - ExamIdenNumber = item.ExamIdenNumber == null ? "-" : item.ExamIdenNumber.ToThaiNumber(), - SeatNumber = item.SeatNumber == null ? "-" : item.SeatNumber.ToThaiNumber(), - PointTotalA = item.PointTotalA == null ? "-" : item.PointTotalA.ToThaiNumber(), - PointA = item.PointA == null ? "-" : item.PointA.ToThaiNumber(), - ResultA = item.ResultA == null ? "-" : item.ResultA.ToThaiNumber(), - PointTotalB = item.PointTotalB == null ? "-" : item.PointTotalB.ToThaiNumber(), - PointB = item.PointB == null ? "-" : item.PointB.ToThaiNumber(), - ResultB = item.ResultB == null ? "-" : item.ResultB.ToThaiNumber(), - PointTotalC = item.PointTotalC == null ? "-" : item.PointTotalC.ToThaiNumber(), - PointC = item.PointC == null ? "-" : item.PointC.ToThaiNumber(), - ResultC = item.ResultC == null ? "-" : item.ResultC.ToThaiNumber(), - Pass = item.Pass == null ? "-" : item.Pass.ToThaiNumber(), - CreatedAt = item.CreatedAt.Date == null ? "-" : item.CreatedAt.Date.ToThaiShortDate().ToThaiNumber(), - RegisterDate = item.RegisterDate.Value.Date == null ? "-" : $"{item.RegisterDate.Value.Date.ToThaiShortDate()} {item.RegisterDate.Value.ToString("HH:mm:ss.ffff")}".ToThaiNumber() - }); num = num + 1; } }