public ActionResult DeleteApplicant(int?applicantId) { if (applicantId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ApplicantDTO applicantDTO = service.GetApplicant(applicantId); if (applicantDTO == null) { return(HttpNotFound()); } return(View(new ApplicantViewModel() { Id = applicantDTO.Id, Surname = applicantDTO.Surname, Name = applicantDTO.Name, Patronym = applicantDTO.Patronym, EmailApp = applicantDTO.EmailApp, City = applicantDTO.City, Region = applicantDTO.Region, Education = applicantDTO.Education, Math = applicantDTO.Math, UkrLanguage = applicantDTO.UkrLanguage, EngLanguage = applicantDTO.EngLanguage, FacultyId = applicantDTO.FacultyId, Faculty = applicantDTO.Faculty })); }
public void MakeApplicant(ApplicantDTO applicantDto) { Faculty faculty = Database.Faculties.Get(applicantDto.FacultyId); // валидация if (faculty == null) { throw new ValidationException("Факультет не найден", ""); } Applicant applicant = new Applicant { Surname = applicantDto.Surname, Name = applicantDto.Name, Patronym = applicantDto.Patronym, EmailApp = applicantDto.EmailApp, City = applicantDto.City, Region = applicantDto.Region, Education = applicantDto.Education, Math = applicantDto.Math, UkrLanguage = applicantDto.UkrLanguage, EngLanguage = applicantDto.EngLanguage, FacultyId = faculty.Id, Faculty = faculty }; Database.Applicants.Create(applicant); Database.Save(); }
public ActionResult AddApplicantToJobOpening(int personId, int jobOpeningId, string email, string name, string comments) { if (Session[SessionConstants.Company] == null) { return(Json(null, JsonRequestBehavior.AllowGet)); } JobOfferDTO jobOpening = new JobOfferDTO(); jobOpening.JobOfferId = jobOpeningId; PersonDTO person = new PersonDTO(); person.PersonId = personId; person.Name = name; person.Email = email; RecruitmentProcessDTO process = new RecruitmentProcessDTO(); ApplicantDTO applicant = new ApplicantDTO(); applicant.JobOffer = jobOpening; applicant.Person = person; process.Applicant = applicant; RecruitmentProcessDTO result = processModel.Start(process, comments); if (result.State == RecruitmentProcessState.Started) { UpdateCompany(); } return(Json(new { state = result.State }, JsonRequestBehavior.AllowGet)); }
public void Start_ExistingEmail_PersonInProcessAlreadyReturn() { JobOfferDTO jobOpening = new JobOfferDTO(); jobOpening.JobOfferId = 1; PersonDTO person = new PersonDTO(); person.Name = "Carlos 2"; person.Email = "*****@*****.**"; RecruitmentProcessDTO process = new RecruitmentProcessDTO(); ApplicantDTO applicant = new ApplicantDTO(); applicant.JobOffer = jobOpening; applicant.Person = person; process.Applicant = applicant; string comments = "Tiene los conocimientos que se requieren para el Rol"; RecruitmentProcessDTO dto = new RecruitmentProcess().Start(process, comments); Assert.AreEqual(RecruitmentProcessState.PersonInProcessAlready, dto.State); }
public void Start_StartRecuitmentProcessWithNewPerson_ProcesStarted() { JobOfferDTO jobOpening = new JobOfferDTO(); jobOpening.JobOfferId = 1; PersonDTO person = new PersonDTO(); person.PersonId = 0; person.Name = "Juana Galindo"; person.Email = "*****@*****.**"; RecruitmentProcessDTO process = new RecruitmentProcessDTO(); ApplicantDTO applicant = new ApplicantDTO(); applicant.JobOffer = jobOpening; applicant.Person = person; process.Applicant = applicant; string comments = "Tiene los conocimientos que se requieren para el Rol"; RecruitmentProcessDTO dto = new RecruitmentProcess().Start(process, comments); Assert.AreEqual(RecruitmentProcessState.PersonInProcessAlready, dto.State); }
public ActionResult AllInfoApplicant(int applicantId) { ApplicantDTO applicantDto = service.GetApplicant(applicantId); FacultyDTO facultyDTO = service.GetFaculty(applicantDto.FacultyId); ApplicantViewModel applicantViewModel = new ApplicantViewModel() { Id = applicantDto.Id, Surname = applicantDto.Surname, Name = applicantDto.Name, Patronym = applicantDto.Patronym, EmailApp = applicantDto.EmailApp, City = applicantDto.City, Region = applicantDto.Region, Education = applicantDto.Education, Math = applicantDto.Math, UkrLanguage = applicantDto.UkrLanguage, EngLanguage = applicantDto.EngLanguage, FacultyId = applicantDto.FacultyId, Faculty = new Faculty() { Id = facultyDTO.Id, Name = facultyDTO.Name, QtyBudget = facultyDTO.QtyBudget, QtyAll = facultyDTO.QtyAll, Applicants = facultyDTO.Applicants } }; return(View(applicantViewModel)); }
public ActionResult <ApplicantDTO> Update([FromBody] ApplicantDTO dto) { if (ModelState.IsValid) { try { _logger.LogInformation($"Updating record with name {dto.Name} "); _repo.UpdateApplicant(dto); _message = $"Record updated successfully with name {dto.Name} "; _logger.LogInformation(_message); return(Ok(_message)); } catch (Exception ex) { _logger.LogInformation($"Failed to update record with name {dto.Name}, Error {ex.Message}"); return(BadRequest(ex)); } } else { StringBuilder errors = Errors(); _logger.LogInformation($"Validation errors for record with name {dto.Name} erros : {errors} "); return(BadRequest(errors)); } }
public async Task <ApplicantDTO> InsertApplicantAsync(ApplicantDTO applicant) { var dto = applicant.Map <ApplicantDTO, Applicant>(); _applicantRepository.Insert(dto); var entity = await _applicantRepository.SaveAsync(dto); return(entity.Map <Applicant, ApplicantDTO>()); }
public static Applicant ToDO(ApplicantDTO dto) { var applicant = new Applicant() { PersonId = dto.PersonId, PersonName = dto.PersonName }; return(applicant); }
public static ApplicantDTO ToDTO(Applicant applicant) { var dto = new ApplicantDTO() { PersonId = applicant.PersonId, PersonName = applicant.PersonName, ApplicantType = applicant.PersonType.ToString(), }; return(dto); }
public async Task <ActionResult <ApplicantDTO> > GetApplicant(int id) { ApplicantDTO applicant = await _applicantService.GetApplicantByIdAsync(id); if (applicant == null) { _logger.LogTrace("Applicant not found with Id" + id); return(NotFound()); } return(applicant); }
public async Task <string> SaveApplicant(ApplicantDTO data) { try { ApplicantProfile applicant = new ApplicantProfile(); applicant.FirstnameTh = data.ApplicantProfile.FirstnameTh; applicant.LastnameTh = data.ApplicantProfile.LastnameTh; applicant.FirstnameEn = data.ApplicantProfile.FirstnameEn; applicant.LastnameEn = data.ApplicantProfile.LastnameEn; applicant.Birthday = data.ApplicantProfile.Birthday; applicant.Age = data.ApplicantProfile.Age; applicant.IdCard = data.ApplicantProfile.IdCard; applicant.Gender = data.ApplicantProfile.Gender; applicant.Status = data.ApplicantProfile.Status; applicant.Height = data.ApplicantProfile.Height; applicant.Weight = data.ApplicantProfile.Weight; applicant.Nationality = data.ApplicantProfile.Nationality; applicant.Tel = data.ApplicantProfile.Tel; applicant.Email = data.ApplicantProfile.Email; applicant.Address = data.ApplicantProfile.Address; applicant.Province = data.ApplicantProfile.Province; applicant.District = data.ApplicantProfile.District; applicant.SubDistrict = data.ApplicantProfile.SubDistrict; applicant.PostalCode = data.ApplicantProfile.PostalCode.ToString(); applicant.ImgPath = data.ApplicantProfile.ImgPath; applicant.Position = data.ApplicantProfile.Position; applicant.Salary = data.ApplicantProfile.Salary; applicant.CrBy = data.ApplicantProfile.CrBy; applicant.CrDate = data.ApplicantProfile.CrDate; applicant.UpdBy = data.ApplicantProfile.UpdBy; applicant.UpdDate = data.ApplicantProfile.UpdDate; applicant.StatusApplicant = "SSSS"; Context.ApplicantProfile.Add(applicant); Context.SaveChanges(); return("Success"); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Create(ApplicantDTO applicantDto) { var applicant = _mapper.Map <Applicant>(applicantDto); await _repo.Create(applicant); if (await _repo.SaveAll()) { return(CreatedAtRoute("CreateApplicant", new { id = applicant.Id }, applicant)); } return(BadRequest("creation unsuccessful")); }
public async Task <IActionResult> PutApplicant(int id, ApplicantDTO applicant) { if (id != applicant.Id) { return(BadRequest()); } if (await _applicantService.UpdateApplicantAsync(applicant) == null) { _logger.LogTrace("Applicant not found for edit with Id" + applicant.Id); return(NotFound()); } return(NoContent()); }
public async Task <ApplicantDTO> UpdateApplicantAsync(ApplicantDTO applicant) { var entity = await _applicantRepository.FindByIdAync(applicant.Id); if (entity == null) { return(null); } var dto = applicant.Map <ApplicantDTO, Applicant>(); _applicantRepository.Update(dto); entity = await _applicantRepository.SaveAsync(dto); return(entity.Map <Applicant, ApplicantDTO>()); }
public ApplicantDTO AddApplicant(ApplicantDTO dTO) { try { _mapper = new Mapper(configDtoToMain); Applicant dbObject = _mapper.Map <Applicant>(dTO); _context.Applicant.Add(dbObject); _context.SaveChanges(); dTO.Id = dbObject.Id; return(dTO); } catch (Exception ex) { throw ex; } }
public IHttpActionResult Applying(ApplicantDTO applicantDTO) { if (!ModelState.IsValid) { return(BadRequest()); } var applicant = Mapper.Map <ApplicantDTO, Applicant>(applicantDTO); _context.Applicants.Add(applicant); _context.SaveChanges(); applicantDTO.id = applicant.id; return(Created(new Uri(Request.RequestUri + "/" + applicant.id), applicantDTO)); }
public ApplicantDTO UpdateApplicant(ApplicantDTO dTO) { try { var data = _context.Applicant.Where(a => a.Age == 18); _mapper = new Mapper(configDtoToMain); Applicant dbObject = _mapper.Map <Applicant>(dTO); _context.Applicant.Update(dbObject); _context.SaveChanges(); return(dTO); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Update(ApplicantDTO applicantDto) { var applicant = _mapper.Map <Applicant>(applicantDto); var thisApplicant = await _repo.Get(applicant.Id); if (thisApplicant == null) { return(BadRequest("Applicant not found")); } if (await _repo.SaveAll()) { return(NoContent()); } return(BadRequest("Update unsuccessful")); }
public void Start_JobOfferingIdIsNotSent_JobOpeningNotSentResult() { JobOfferDTO jobOpening = new JobOfferDTO(); jobOpening.JobOfferId = 0; RecruitmentProcessDTO process = new RecruitmentProcessDTO(); ApplicantDTO applicant = new ApplicantDTO(); applicant.JobOffer = jobOpening; process.Applicant = applicant; string comments = "Tiene los conocimientos que se requieren para el Rol"; RecruitmentProcessDTO dto = new RecruitmentProcess().Start(process, comments); Assert.AreEqual(RecruitmentProcessState.JobOpeningNotSent, dto.State); }
public void UpdateApplicant(ApplicantDTO applicantDTO) { Database.Applicants.Update(new Applicant() { Id = applicantDTO.Id, Surname = applicantDTO.Surname, Name = applicantDTO.Name, Patronym = applicantDTO.Patronym, EmailApp = applicantDTO.EmailApp, City = applicantDTO.City, Region = applicantDTO.Region, Education = applicantDTO.Education, Math = applicantDTO.Math, UkrLanguage = applicantDTO.UkrLanguage, EngLanguage = applicantDTO.EngLanguage, FacultyId = applicantDTO.FacultyId, Faculty = applicantDTO.Faculty }); }
public async Task <IActionResult> PutApplicant([FromRoute] int id, [FromBody] ApplicantDTO applicant) { if (id != applicant.Id || !ModelState.IsValid) { return(BadRequest()); } var previousHiredStatus = _applicantService.GetApplicantById(id).Hired; if (_applicantService.CreateOrUpdateApplicant(applicant)) { return(NoContent()); } else { var applicantJsonStr = JsonConvert.SerializeObject(applicant); _logger.Error("Applicant Update failed for following applicant:" + applicantJsonStr); return(BadRequest()); } }
public IHttpActionResult UpdateApplying(int id, ApplicantDTO applicantDTO) { if (!ModelState.IsValid) { return(BadRequest()); } var applicant = _context.Applicants.SingleOrDefault(c => c.id == id); if (applicant == null) { NotFound(); } Mapper.Map(applicantDTO, applicant); _context.SaveChanges(); return(Ok()); }
public async Task <ActionResult <ApplicantDTO> > PostApplicant([FromBody] ApplicantDTO applicant) { if (ModelState.IsValid) { if (_applicantService.CreateOrUpdateApplicant(applicant)) { var savedApplicant = _applicantService.GetAllApplicant().Where(x => x.EmailAddress == applicant.EmailAddress).FirstOrDefault(); return(CreatedAtAction("GetApplicant", new { id = savedApplicant.Id }, applicant)); } else { var applicantJsonStr = JsonConvert.SerializeObject(applicant); _logger.Error("Applicant Creation failed for following applicant:" + applicantJsonStr); return(BadRequest()); } } else { return(BadRequest()); } }
public void Start_PersonDataIncomplete_IncompletePersonDataResult() { JobOfferDTO jobOpening = new JobOfferDTO(); jobOpening.JobOfferId = 1; PersonDTO person = new PersonDTO(); RecruitmentProcessDTO process = new RecruitmentProcessDTO(); ApplicantDTO applicant = new ApplicantDTO(); applicant.JobOffer = jobOpening; applicant.Person = person; process.Applicant = applicant; string comments = "Tiene los conocimientos que se requieren para el Rol"; RecruitmentProcessDTO dto = new RecruitmentProcess().Start(process, comments); Assert.AreEqual(RecruitmentProcessState.IncompletePersonData, dto.State); }
public ActionResult <ApplicantDTO> Add([FromBody] ApplicantDTO dto) { if (ModelState.IsValid) { try { dto = _repo.AddApplicant(dto); _logger.LogInformation($"Applicant record inserted successfully with name {dto.Name} "); return(CreatedAtRoute("Get", new { id = dto.Id }, dto)); } catch (Exception ex) { _logger.LogInformation($"Failed to insert record with name {dto.Name}, Error {ex.Message}"); return(BadRequest(ex)); } } else { StringBuilder errors = Errors(); _logger.LogInformation($"Validation errors for record with name {dto.Name} erros : {errors} "); return(BadRequest(errors)); } }
public async Task <ActionResult <ApplicantDTO> > PostApplicant(ApplicantDTO applicant) { applicant = await _applicantService.InsertApplicantAsync(applicant); return(CreatedAtAction("GetApplicant", new { id = applicant.Id }, applicant)); }
public ApplicantDTO GetDataProfileByID(int empID) { ApplicantDTO listData = new ApplicantDTO(); ApplicantProfile applicantProfile = new ApplicantProfile(); ApplicantSkill applicantSkill = new ApplicantSkill(); List <ApplicantEduHistory> applicantEduHis = new List <ApplicantEduHistory>(); List <ApplicantWorkingHistory> applicantWorkingHistories = new List <ApplicantWorkingHistory>(); List <ApplicantTrainingHistory> applicantTrainingHistories = new List <ApplicantTrainingHistory>(); List <ApplicantSkillLanguage> applicantSkillLanguages = new List <ApplicantSkillLanguage>(); List <ApplicantRef> applicantRefs = new List <ApplicantRef>(); applicantProfile = Context.ApplicantProfile.Where(x => x.Empid == empID).FirstOrDefault(); applicantSkill = Context.ApplicantSkill.Where(x => x.Empid == empID).FirstOrDefault(); applicantEduHis = Context.ApplicantEduHistory.Where(x => x.Empid == empID).ToList(); applicantWorkingHistories = Context.ApplicantWorkingHistory.Where(x => x.Empid == empID).ToList(); applicantTrainingHistories = Context.ApplicantTrainingHistory.Where(x => x.Empid == empID).ToList(); applicantSkillLanguages = Context.ApplicantSkillLanguage.Where(x => x.Empid == empID).ToList(); applicantRefs = Context.ApplicantRef.Where(x => x.Empid == empID).ToList(); listData.ApplicantProfile.TitelnameTh = applicantProfile.TitlenameTh; listData.ApplicantProfile.FirstnameTh = string.IsNullOrEmpty(applicantProfile.FirstnameTh) ? "" : applicantProfile.FirstnameTh; listData.ApplicantProfile.LastnameTh = string.IsNullOrEmpty(applicantProfile.LastnameTh) ? "" : applicantProfile.LastnameTh; listData.ApplicantProfile.TitelnameEn = applicantProfile.TitlenameEn; listData.ApplicantProfile.FirstnameEn = string.IsNullOrEmpty(applicantProfile.FirstnameEn) ? "" : applicantProfile.FirstnameEn; listData.ApplicantProfile.LastnameEn = string.IsNullOrEmpty(applicantProfile.LastnameEn) ? "" : applicantProfile.LastnameEn; listData.ApplicantProfile.Birthday = applicantProfile.Birthday; listData.ApplicantProfile.Age = applicantProfile.Age != null ? applicantProfile.Age : 0; listData.ApplicantProfile.IdCard = string.IsNullOrEmpty(applicantProfile.IdCard) ? "" : applicantProfile.IdCard; listData.ApplicantProfile.Status = string.IsNullOrEmpty(applicantProfile.Status) ? "" : applicantProfile.Status; listData.ApplicantProfile.Height = applicantProfile.Height != null ? applicantProfile.Height : 0; listData.ApplicantProfile.Weight = applicantProfile.Weight != null ? applicantProfile.Weight : 0; listData.ApplicantProfile.Nationality = string.IsNullOrEmpty(applicantProfile.Nationality) ? "" : applicantProfile.Nationality; listData.ApplicantProfile.Religion = string.IsNullOrEmpty(applicantProfile.Religion) ? "" : applicantProfile.Religion; listData.ApplicantProfile.Tel = string.IsNullOrEmpty(applicantProfile.Tel) ? "" : applicantProfile.Tel; listData.ApplicantProfile.Email = string.IsNullOrEmpty(applicantProfile.Email) ? "" : applicantProfile.Email; listData.ApplicantProfile.LineID = applicantProfile.Lineid; listData.ApplicantProfile.Address = string.IsNullOrEmpty(applicantProfile.Address) ? "" : applicantProfile.Address; listData.ApplicantProfile.Province = string.IsNullOrEmpty(applicantProfile.Province) ? "" : applicantProfile.Province; listData.ApplicantProfile.District = string.IsNullOrEmpty(applicantProfile.District) ? "" : applicantProfile.District; listData.ApplicantProfile.SubDistrict = string.IsNullOrEmpty(applicantProfile.SubDistrict) ? "" : applicantProfile.SubDistrict; listData.ApplicantProfile.PostalCode = int.Parse(applicantProfile.PostalCode); listData.ApplicantProfile.Stay = applicantProfile.Stay; listData.ApplicantProfile.ImgPath = string.IsNullOrEmpty(applicantProfile.ImgPath) ? "" : applicantProfile.ImgPath; listData.ApplicantProfile.Position = string.IsNullOrEmpty(applicantProfile.Position) ? "" : applicantProfile.Position; listData.ApplicantProfile.Salary = string.IsNullOrEmpty(applicantProfile.Salary) ? "" : applicantProfile.Salary; listData.ApplicantProfile.TypeEmployee = string.IsNullOrEmpty(applicantProfile.TypeEmployee) ? "" : applicantProfile.TypeEmployee; listData.ApplicantSkill.TypingTh = applicantSkill.TypingTh != null ? applicantSkill.TypingTh : 0; listData.ApplicantSkill.TypingEn = applicantSkill.TypingEn != null ? applicantSkill.TypingEn : 0; listData.ApplicantSkill.Special1 = string.IsNullOrEmpty(applicantSkill.Special1) ? "" : applicantSkill.Special1; listData.ApplicantSkill.Special2 = string.IsNullOrEmpty(applicantSkill.Special2) ? "" : applicantSkill.Special2; listData.ApplicantSkill.Special3 = string.IsNullOrEmpty(applicantSkill.Special3) ? "" : applicantSkill.Special3; listData.ApplicantSkill.Special4 = string.IsNullOrEmpty(applicantSkill.Special4) ? "" : applicantSkill.Special4; listData.ApplicantProfile.CrBy = string.IsNullOrEmpty(applicantProfile.CrBy) ? "" : applicantProfile.CrBy; listData.ApplicantProfile.CrDate = applicantProfile.CrDate; listData.ApplicantProfile.Gender = string.IsNullOrEmpty(applicantProfile.Gender) ? "" : applicantProfile.Gender; listData.ApplicantProfile.StatusApplicant = string.IsNullOrEmpty(applicantProfile.StatusApplicant) ? "" : applicantProfile.StatusApplicant; listData.ApplicantProfile.FirstnameTh = string.IsNullOrEmpty(applicantProfile.FirstnameTh) ? "" : applicantProfile.FirstnameTh; listData.ApplicantProfile.UpdBy = string.IsNullOrEmpty(applicantProfile.UpdBy) ? "" : applicantProfile.UpdBy; listData.ApplicantProfile.UpdDate = applicantProfile.UpdDate; foreach (ApplicantEduHistory eduHistory in applicantEduHis) { if (eduHistory != null) { ApplicantEduHistoryDTO eduHistoryDTO = new ApplicantEduHistoryDTO(); eduHistoryDTO.Education = eduHistory.Education; eduHistoryDTO.SchoolName = eduHistory.SchoolName; eduHistoryDTO.Faculty = eduHistory.Faculty; eduHistoryDTO.Major = eduHistory.Major; eduHistoryDTO.GradYear = DateTime.Parse("01/01/" + eduHistory.GradYear); eduHistoryDTO.Gpa = eduHistory.Gpa; listData.ApplicantEduHistories.Add(eduHistoryDTO); } else { listData.ApplicantEduHistories = null; } } foreach (ApplicantWorkingHistory workingHistory in applicantWorkingHistories) { if (workingHistory != null) { ApplicantWorkingHistoryDTO workingHistoryDTO = new ApplicantWorkingHistoryDTO(); workingHistoryDTO.StartDate = workingHistory.StartDate; workingHistoryDTO.EndDate = workingHistory.EndDate; workingHistoryDTO.CompanyName = workingHistory.CompanyName; workingHistoryDTO.CompanyAddress = workingHistory.CompanyAddress; workingHistoryDTO.Position = workingHistory.Position; workingHistoryDTO.Salary = workingHistory.Salary; listData.ApplicantWorkingHistories.Add(workingHistoryDTO); } else { listData.ApplicantWorkingHistories = null; } } foreach (ApplicantTrainingHistory trainingHistory in applicantTrainingHistories) { if (trainingHistory != null) { ApplicantTrainingHistoryDTO trainingHistoryDTO = new ApplicantTrainingHistoryDTO(); trainingHistoryDTO.StartDate = trainingHistory.StartDate; trainingHistoryDTO.EndDate = trainingHistory.EndDate; trainingHistoryDTO.TrainingName = trainingHistory.TrainingName; trainingHistoryDTO.CourseName = trainingHistory.CourseName; trainingHistoryDTO.Certificate = trainingHistory.Certificate; listData.ApplicantTrainingHistories.Add(trainingHistoryDTO); } else { listData.ApplicantTrainingHistories = null; } } foreach (ApplicantSkillLanguage skillLanguage in applicantSkillLanguages) { if (skillLanguage != null) { ApplicantSkillLanguageDTO skillLanguageDTO = new ApplicantSkillLanguageDTO(); skillLanguageDTO.Language = skillLanguage.Language; skillLanguageDTO.LanguageSpeak = skillLanguage.LanguageSpeak; skillLanguageDTO.LanguageRead = skillLanguage.LanguageRead; skillLanguageDTO.LanguageWrite = skillLanguage.LanguageWrite; listData.ApplicantSkillLanguages.Add(skillLanguageDTO); } else { listData.ApplicantTrainingHistories = null; } } foreach (ApplicantRef Ref in applicantRefs) { if (Ref != null) { ApplicantRefDTO RefDTO = new ApplicantRefDTO(); RefDTO.RefName = Ref.RefName; RefDTO.RefPosition = Ref.RefPosition; RefDTO.RefTel = Ref.RefTel; listData.ApplicantRef.Add(RefDTO); } else { listData.ApplicantRef = null; } } return(listData); }
public async Task <string> SaveApplicant(ApplicantDTO data) { using (var dbContextTransaction = Context.Database.BeginTransaction()) { try { int empID = Context.ApplicantProfile.Max(i => i.Empid) + 1; // EMDID DateTime dateTime = DateTime.Now; #region // ########## Table APPLICANT_PROFILE ########## // ApplicantProfile applicant = new ApplicantProfile(); // EMDID applicant.Empid = empID; // รูปโปรไฟล์ applicant.ImgPath = data.ApplicantProfile.ImgPath; // ลักษณะงานที่ต้องการ applicant.Position = data.ApplicantProfile.Position; applicant.Salary = data.ApplicantProfile.Salary; applicant.TypeEmployee = data.ApplicantProfile.TypeEmployee; // ข้อมูลส่วนตัว applicant.TitlenameTh = data.ApplicantProfile.TitelnameTh; applicant.FirstnameTh = data.ApplicantProfile.FirstnameTh; applicant.LastnameTh = data.ApplicantProfile.LastnameTh; applicant.TitlenameEn = data.ApplicantProfile.TitelnameEn; applicant.FirstnameEn = data.ApplicantProfile.FirstnameEn; applicant.LastnameEn = data.ApplicantProfile.LastnameEn; applicant.Birthday = data.ApplicantProfile.Birthday; applicant.Age = data.ApplicantProfile.Age; applicant.Gender = data.ApplicantProfile.Gender; applicant.Status = data.ApplicantProfile.Status; applicant.IdCard = data.ApplicantProfile.IdCard; applicant.Religion = data.ApplicantProfile.Religion; applicant.Nationality = data.ApplicantProfile.Nationality; applicant.Height = data.ApplicantProfile.Height; applicant.Weight = data.ApplicantProfile.Weight; // ข้อมูลการติดต่อ applicant.Tel = data.ApplicantProfile.Tel; applicant.Email = data.ApplicantProfile.Email; applicant.Lineid = data.ApplicantProfile.LineID; // ข้อมูลที่อยู่ปัจจุบัน applicant.Address = data.ApplicantProfile.Address; applicant.Province = data.ApplicantProfile.Province; applicant.District = data.ApplicantProfile.District; applicant.SubDistrict = data.ApplicantProfile.SubDistrict; applicant.PostalCode = data.ApplicantProfile.PostalCode.ToString(); // Status applicant.StatusApplicant = "New"; applicant.CrBy = "Coop";; applicant.CrDate = dateTime; applicant.UpdBy = "Coop"; applicant.UpdDate = dateTime; Context.ApplicantProfile.Add(applicant); #endregion #region // ########## Table APPLICANT_EDU_HISTORY ########## // int eduNo = 0; foreach (ApplicantEduHistoryDTO edu in data.ApplicantEduHistories) { ApplicantEduHistory applicantEdu = new ApplicantEduHistory(); eduNo++; // EMPID applicantEdu.Empid = empID; // ประวัติการศึกษา applicantEdu.No = eduNo; applicantEdu.Education = edu.Education; applicantEdu.SchoolName = edu.SchoolName; applicantEdu.Faculty = edu.Faculty; applicantEdu.Major = edu.Major; applicantEdu.GradYear = edu.GradYear.Year.ToString(); applicantEdu.Gpa = edu.Gpa; applicantEdu.CrBy = "Coop"; applicantEdu.CrDate = dateTime; applicantEdu.UpdBy = "Coop"; applicantEdu.UpdDate = dateTime; Context.ApplicantEduHistory.Add(applicantEdu); } #endregion #region // ########## Table APPLICANT_WORKING_HISTORY ########## // int workNo = 0; foreach (ApplicantWorkingHistoryDTO work in data.ApplicantWorkingHistories) { ApplicantWorkingHistory applicantWork = new ApplicantWorkingHistory(); workNo++; // EMPID applicantWork.Empid = empID; // ประวัติการทำงาน/ฝึกงาน applicantWork.No = workNo; applicantWork.StartDate = work.StartDate; applicantWork.EndDate = work.EndDate; applicantWork.CompanyName = work.CompanyName; applicantWork.CompanyAddress = work.CompanyAddress; applicantWork.Position = work.Position; applicantWork.Salary = work.Salary; applicantWork.CrBy = "Coop"; applicantWork.CrDate = dateTime; applicantWork.UpdBy = "Coop"; applicantWork.UpdDate = dateTime; Context.ApplicantWorkingHistory.Add(applicantWork); } #endregion #region // ########## Table APPLICANT_TRAINING_HISTORY ########## // int trainingNo = 0; foreach (ApplicantTrainingHistoryDTO training in data.ApplicantTrainingHistories) { ApplicantTrainingHistory applicantTraining = new ApplicantTrainingHistory(); trainingNo++; // EMPID applicantTraining.Empid = empID; // ประวัติการฝึกอบรม/ประกาศนียบัตร applicantTraining.No = trainingNo; applicantTraining.StartDate = training.StartDate; applicantTraining.EndDate = training.EndDate; applicantTraining.TrainingName = training.TrainingName; applicantTraining.CourseName = training.CourseName; applicantTraining.Certificate = training.Certificate; applicantTraining.CrBy = "Coop"; applicantTraining.CrDate = dateTime; applicantTraining.UpdBy = "Coop"; applicantTraining.UpdDate = dateTime; Context.ApplicantTrainingHistory.Add(applicantTraining); } #endregion #region // ########## Table APPLICANT_SKILL_LANGUAGE ########## // int languageNo = 0; foreach (ApplicantSkillLanguageDTO language in data.ApplicantSkillLanguages) { ApplicantSkillLanguage applicantLanguage = new ApplicantSkillLanguage(); languageNo++; // EMPID applicantLanguage.Empid = empID; // ความสามารถทางภาษา applicantLanguage.No = languageNo; applicantLanguage.Language = language.Language; applicantLanguage.LanguageSpeak = language.LanguageSpeak; applicantLanguage.LanguageRead = language.LanguageRead; applicantLanguage.LanguageWrite = language.LanguageWrite; applicantLanguage.CrBy = "Coop"; applicantLanguage.CrDate = dateTime; applicantLanguage.UpdBy = "Coop"; applicantLanguage.UpdDate = dateTime; Context.ApplicantSkillLanguage.Add(applicantLanguage); } #endregion #region // ########## Table APPLICANT_SKILL ########## // ApplicantSkill applicantSkill = new ApplicantSkill(); // EMPID applicantSkill.Empid = empID; // พิมพ์ดีด applicantSkill.TypingTh = data.ApplicantSkill.TypingTh; applicantSkill.TypingEn = data.ApplicantSkill.TypingEn; // กรุณาเรียงลำดับความสามารถด้านคอมพิวเตอร์ (เช่นภาษา/โปรแกรม/ระบบปฏิบัติการอื่นๆ) applicantSkill.Special1 = data.ApplicantSkill.Special1; applicantSkill.Special2 = data.ApplicantSkill.Special2; applicantSkill.Special3 = data.ApplicantSkill.Special3; applicantSkill.Special4 = data.ApplicantSkill.Special4; applicantSkill.CrBy = "Coop"; applicantSkill.CrDate = dateTime; applicantSkill.UpdBy = "Coop"; applicantSkill.UpdDate = dateTime; Context.ApplicantSkill.Add(applicantSkill); #endregion #region // ########## Table APPLICANT_REF ########## // int refNo = 0; foreach (ApplicantRefDTO refs in data.ApplicantRef) { ApplicantRef applicantRef = new ApplicantRef(); refNo++; // EMPID applicantRef.Empid = empID; // รายชื่อบุคคลอ้างอิง ซึ่งมิใช่ญาติหรือผู้ว่าจ้าง ซึ่งบริษัทฯ สามารถสอบประวัติท่านได้ applicantRef.No = refNo; applicantRef.RefName = refs.RefName; applicantRef.RefPosition = refs.RefPosition; applicantRef.RefTel = refs.RefTel; applicantRef.CrBy = "Coop"; applicantRef.CrDate = dateTime; applicantRef.UpdBy = "Coop"; applicantRef.UpdDate = dateTime; Context.ApplicantRef.Add(applicantRef); } #endregion Context.SaveChanges(); dbContextTransaction.Commit(); return(empID.ToString()); } catch (Exception ex) { dbContextTransaction.Rollback(); return("error"); } } }
public override RecruitmentProcessDTO Execute(RecruitmentProcessDTO process, string comments) { //Invalid Job Offer Id if (process.Applicant.JobOffer.JobOfferId <= 0) { process.State = RecruitmentProcessState.JobOpeningNotSent; return(process); } //Incomplete Person Data if ( (process.Applicant.Person.PersonId == 0 && String.IsNullOrEmpty(process.Applicant.Person.Email)) || (process.Applicant.Person.PersonId == 0 && !String.IsNullOrEmpty(process.Applicant.Person.Email) && !PersonEmailExistsAlready(process.Applicant.Person.Email) && String.IsNullOrEmpty(process.Applicant.Person.Name)) || (process.Applicant.Person.PersonId == 0 && String.IsNullOrEmpty(process.Applicant.Person.Email)) && String.IsNullOrEmpty(process.Applicant.Person.Name)) { process.State = RecruitmentProcessState.IncompletePersonData; return(process); } //New Person? Then we need to create it if (process.Applicant.Person.PersonId == 0 && !PersonEmailExistsAlready(process.Applicant.Person.Email)) { process.Applicant.Person.DateCreated = DateTime.Now; process.Applicant.Person.Title = ""; process.Applicant.Person = db.People.Add(process.Applicant.Person); db.SaveChanges(); } else { //Person Sent? Check that it exists if (process.Applicant.Person.PersonId > 0) { if (new Person().Get(process.Applicant.Person.PersonId) == null) { process.State = RecruitmentProcessState.PersonNotFound; return(process); } } //Person not sent & Email Sent? Check it exists if (process.Applicant.Person.PersonId == 0 && !String.IsNullOrEmpty(process.Applicant.Person.Email) && PersonEmailExistsAlready(process.Applicant.Person.Email)) { process.Applicant.Person = new Person().GetByEmail(process.Applicant.Person.Email); } //Check Person is not not Process already if (PersonIdInJobOpeningAlready(process.Applicant.Person.PersonId, process.Applicant.JobOffer.JobOfferId)) { process.State = RecruitmentProcessState.PersonInProcessAlready; return(process); } } ApplicantDTO applicant = new ApplicantDTO(); applicant.JobOfferId = process.Applicant.JobOffer.JobOfferId; applicant.PersonId = process.Applicant.Person.PersonId; applicant.DateCreated = DateTime.Now; applicant = db.Applicants.Add(applicant); db.SaveChanges(); process.Applicant = applicant; process.State = RecruitmentProcessState.Started; process.DateUpdated = DateTime.Now; process = db.RecruitmentProcesses.Add(process); RecruitmentProcessStepDTO step = new RecruitmentProcessStepDTO(); step.Name = "CandidateCreated"; step.DateCreated = DateTime.Now; step.RecruitmentProcessId = process.RecruitmentProcessId; db.RecruitmentProcessSteps.Add(step); db.SaveChanges(); return(process); }