From 8d64f8bb4a74d1a3d8ac10dcfd84e5cdc453aac2 Mon Sep 17 00:00:00 2001 From: AnandaTon <125332905+anandaAiemvong@users.noreply.github.com> Date: Thu, 30 Mar 2023 15:07:35 +0700 Subject: [PATCH 1/2] =?UTF-8?q?=E0=B8=95=E0=B9=88=E0=B8=AD=20Api=20period?= =?UTF-8?q?=20exam?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/PeriodExamController.cs | 25 +++++++++++++++++++++++++ Services/PeriodExamService.cs | 27 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/Controllers/PeriodExamController.cs b/Controllers/PeriodExamController.cs index 91730b9..54096a3 100644 --- a/Controllers/PeriodExamController.cs +++ b/Controllers/PeriodExamController.cs @@ -265,7 +265,32 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers return Error(ex); } } + + /// + /// ข้อมูล ข้อมูลส่วนตัว ผู้สมัคร + /// + /// รหัสรอบสมัคร + /// + /// เมื่อทำการดึง ข้อมูล ข้อมูลส่วนตัว ผู้สมัคร สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("information/{candidate:length(36)}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetsAsyncInformation(string candidate) + { + try + { + var items = await _periodExamService.GetsAsyncInformation(candidate); + return Success(items); + } + catch (Exception ex) + { + return Error(ex); + } + } #endregion } } diff --git a/Services/PeriodExamService.cs b/Services/PeriodExamService.cs index 789d2d8..3abc171 100644 --- a/Services/PeriodExamService.cs +++ b/Services/PeriodExamService.cs @@ -143,6 +143,33 @@ namespace BMA.EHR.Recurit.Exam.Service.Services } } + public async Task GetsAsyncInformation(string candidateId) + { + return await _context.Candidates.AsQueryable() + .Where(x => x.Id == Guid.Parse(candidateId)) + .Select(x => new CandidateInformationResponseItem + { + Prefix = x.Prefix, + PrefixId = x.Prefix != null ? x.Prefix.Id.ToString() : null, + FirstName = x.FirstName, + LastName = x.LastName, + Nationality = x.Nationality, + DateOfBirth = x.DateOfBirth, + Relationship = x.Relationship, + RelationshipId = x.Relationship != null ? x.Relationship.Id.ToString() : null, + CitizenProvince = x.CitizenProvince, + CitizenProvinceId = x.CitizenProvince != null ? x.CitizenProvince.Id.ToString() : null, + CitizenDistrict = x.CitizenDistrict, + CitizenDistrictId = x.CitizenDistrict != null ? x.CitizenDistrict.Id.ToString() : null, + CitizenDate = x.CitizenDate, + Email = x.Email, + CitizenId = x.CitizenId, + Telephone = x.Telephone, + MobilePhone = x.MobilePhone, + Knowledge = x.Knowledge, + }) + .FirstOrDefaultAsync(); + } #endregion } } From 2ef1fb3d4af4c471f02b9cc5758d76f1ade038ab Mon Sep 17 00:00:00 2001 From: AnandaTon <125332905+anandaAiemvong@users.noreply.github.com> Date: Thu, 30 Mar 2023 16:24:27 +0700 Subject: [PATCH 2/2] =?UTF-8?q?=E0=B8=95=E0=B9=88=E0=B8=AD=20api=20period?= =?UTF-8?q?=20exam(=E0=B8=95=E0=B9=88=E0=B8=AD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/PeriodExamController.cs | 131 +++++++++++++++++++++++++++- Services/PeriodExamService.cs | 91 +++++++++++++++++++ 2 files changed, 221 insertions(+), 1 deletion(-) diff --git a/Controllers/PeriodExamController.cs b/Controllers/PeriodExamController.cs index 54096a3..d070ec5 100644 --- a/Controllers/PeriodExamController.cs +++ b/Controllers/PeriodExamController.cs @@ -265,7 +265,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers return Error(ex); } } - + /// /// ข้อมูล ข้อมูลส่วนตัว ผู้สมัคร /// @@ -291,6 +291,135 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers return Error(ex); } } + + /// + /// ข้อมูล ข้อมูลที่อยู่ ผู้สมัคร + /// + /// รหัสรอบสมัคร + /// + /// เมื่อทำการดึง ข้อมูล ข้อมูลที่อยู่ ผู้สมัคร สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("address/{candidate:length(36)}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetsAsyncAddress(string candidate) + { + try + { + var items = await _periodExamService.GetsAsyncAddress(candidate); + + return Success(items); + } + catch (Exception ex) + { + return Error(ex); + } + } + + /// + /// ข้อมูล ข้อมูลครอบครัว ผู้สมัคร + /// + /// รหัสรอบสมัคร + /// + /// เมื่อทำการดึง ข้อมูล ข้อมูลครอบครัว ผู้สมัคร สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("family/{candidate:length(36)}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetsAsyncFamily(string candidate) + { + try + { + var items = await _candidateService.GetsAsyncFamily(candidate); + + return Success(items); + } + catch (Exception ex) + { + return Error(ex); + } + } + + /// + /// ข้อมูล อาชีพ ผู้สมัคร + /// + /// รหัสรอบสมัคร + /// + /// เมื่อทำการดึง ข้อมูล อาชีพ ผู้สมัคร สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("occupation/{candidate:length(36)}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetsAsyncOccupation(string candidate) + { + try + { + var items = await _candidateService.GetsAsyncOccupation(candidate); + + return Success(items); + } + catch (Exception ex) + { + return Error(ex); + } + } + + /// + /// ข้อมูล ประวัติการทำงาน/ฝึกงาน ผู้สมัคร + /// + /// รหัสรอบสมัคร + /// + /// เมื่อทำการดึง ข้อมูล ประวัติการทำงาน/ฝึกงาน ผู้สมัคร สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("career/{candidate:length(36)}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetsAsyncCareer(string candidate) + { + try + { + var items = await _candidateService.GetsAsyncCareer(candidate); + + return Success(items); + } + catch (Exception ex) + { + return Error(ex); + } + } + /// + /// ข้อมูล ประวัติการศีกษา ผู้สมัคร + /// + /// รหัสรอบสมัคร + /// + /// เมื่อทำการดึง ข้อมูล ประวัติการศีกษา ผู้สมัคร สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("education/{candidate:length(36)}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> GetsAsyncEducation(string candidate) + { + try + { + var items = await _periodExamService.GetsAsyncEducation(candidate); + + return Success(items); + } + catch (Exception ex) + { + return Error(ex); + } + } #endregion } } diff --git a/Services/PeriodExamService.cs b/Services/PeriodExamService.cs index 3abc171..a01634c 100644 --- a/Services/PeriodExamService.cs +++ b/Services/PeriodExamService.cs @@ -170,6 +170,97 @@ namespace BMA.EHR.Recurit.Exam.Service.Services }) .FirstOrDefaultAsync(); } + public async Task GetsAsyncOccupation(string candidateId) + { + return await _context.Candidates.AsQueryable() + .Where(x => x.Id == Guid.Parse(candidateId)) + .Select(x => new CandidateOccupationResponseItem + { + OccupationType = x.OccupationType, + OccupationCompany = x.OccupationCompany, + OccupationDepartment = x.OccupationDepartment, + OccupationEmail = x.OccupationEmail, + OccupationTelephone = x.OccupationTelephone, + OccupationPosition = x.OccupationPosition, + }) + .FirstOrDefaultAsync(); + } + public async Task> GetsAsyncCareer(string candidateId) + { + return await _context.Careers.AsQueryable() + .Where(x => x.Id == Guid.Parse(candidateId)) + .OrderBy(d => d.DurationStart) + .ToListAsync(); + } + + public async Task GetsAsyncAddress(string candidateId) + { + return await _context.Candidates.AsQueryable() + .Where(x => x.Id == Guid.Parse(candidateId)) + .Select(x => new CandidateAddressResponseItem + { + RegistAddress = x.RegistAddress, + RegistProvince = x.RegistProvince, + RegistProvinceId = x.RegistProvince != null ? x.RegistProvince.Id.ToString() : null, + RegistDistrict = x.RegistDistrict, + RegistDistrictId = x.RegistDistrict != null ? x.RegistDistrict.Id.ToString() : null, + RegistSubDistrict = x.RegistSubDistrict, + RegistSubDistrictId = x.RegistSubDistrict != null ? x.RegistSubDistrict.Id.ToString() : null, + RegistZipCode = x.RegistZipCode, + RegistSame = x.RegistSame, + CurrentAddress = x.CurrentAddress, + CurrentProvince = x.CurrentProvince, + CurrentProvinceId = x.CurrentProvince != null ? x.CurrentProvince.Id.ToString() : null, + CurrentDistrict = x.CurrentDistrict, + CurrentDistrictId = x.CurrentDistrict != null ? x.CurrentDistrict.Id.ToString() : null, + CurrentSubDistrict = x.CurrentSubDistrict, + CurrentSubDistrictId = x.CurrentSubDistrict != null ? x.CurrentSubDistrict.Id.ToString() : null, + CurrentZipCode = x.CurrentZipCode, + }) + .FirstOrDefaultAsync(); + } + public async Task GetsAsyncFamily(string candidateId) + { + return await _context.Candidates.AsQueryable() + .Where(x => x.Id == Guid.Parse(candidateId)) + .Select(x => new CandidateFamilyResponseItem + { + Marry = x.Marry, + MarryPrefix = x.MarryPrefix, + MarryPrefixId = x.MarryPrefix != null ? x.MarryPrefix.Id.ToString() : null, + MarryFirstName = x.MarryFirstName, + MarryLastName = x.MarryLastName, + MarryOccupation = x.MarryOccupation, + MarryNationality = x.MarryNationality, + FatherPrefix = x.FatherPrefix, + FatherPrefixId = x.FatherPrefix != null ? x.FatherPrefix.Id.ToString() : null, + FatherFirstName = x.FatherFirstName, + FatherLastName = x.FatherLastName, + FatherOccupation = x.FatherOccupation, + FatherNationality = x.FatherNationality, + MotherPrefix = x.MotherPrefix, + MotherPrefixId = x.MotherPrefix != null ? x.MotherPrefix.Id.ToString() : null, + MotherFirstName = x.MotherFirstName, + MotherLastName = x.MotherLastName, + MotherOccupation = x.MotherOccupation, + MotherNationality = x.MotherNationality, + }) + .FirstOrDefaultAsync(); + } + public async Task> GetsAsyncEducation(string candidateId) + { + + var candidate = await _context.Candidates.AsQueryable() + .FirstOrDefaultAsync(x => x.PeriodExam == exam && x.UserId == UserId); + + return await _context.Educations.AsQueryable() + .Include(x => x.EducationLevel) + .Where(x => x.Id == Guid.Parse(candidateId)) + .OrderBy(d => d.DurationStart) + .ToListAsync(); + } + + #endregion } }