private FluentValidation.Results.ValidationResult ValidateEditCandidate(EditCandidateViewModel candidateform) { var validator = new EditCandidateValidator(); var result = validator.Validate(candidateform); return(result); }
public ActionResult Edit(int id) { var candidate = _candidateRepository.Get(id, "Person"); if (candidate == null) { return(HttpNotFound()); } var mappedTechnologies = _candidateTechnologyMapRepository.GetAllBy(m => m.CandidateId == candidate.Id).Select(m => m.TechnologyId).ToList(); ViewBag.Technologies = new MultiSelectList(_technologyRepository.GetAll(), "Id", "Title", mappedTechnologies); ViewBag.CandidateDesignationId = new SelectList(_candidateDesignationRepository.GetAll(), "Id", "Title", candidate.DesignationId); var vm = new EditCandidateViewModel(candidate); return(View(vm)); }
private void MapEditCandidateAddress(Address address, EditCandidateViewModel editCandidateViewModel) { address.address_line_1 = editCandidateViewModel.candidate_address_line_1; address.address_line_2 = editCandidateViewModel.candidate_address_line_2; address.taluka_id = editCandidateViewModel.candidate_taluka_id; if (editCandidateViewModel.candidate_state_id != null) { address.state_id = (int)editCandidateViewModel.candidate_state_id; } else { address.state_id = null; } address.district_id = editCandidateViewModel.candidate_district_id; address.zip_code = editCandidateViewModel.candidate_zip_code; address.id = editCandidateViewModel.address_id; }
public ActionResult EditProfile() { return(RedirectIfNotLoggedIn(() => { var candidateId = int.Parse(Session[PortalKeyId].ToString()); var candidate = _candidateRepository.Get(candidateId, "Person"); if (candidate == null) { return HttpNotFound(); } var mappedTechnologies = _candidateTechnologyMapRepository.GetAllBy(m => m.CandidateId == candidate.Id).Select(m => m.TechnologyId).ToList(); ViewBag.Technologies = new MultiSelectList(_technologyRepository.GetAll(), "Id", "Title", mappedTechnologies); ViewBag.CandidateDesignationId = new SelectList(_candidateDesignationRepository.GetAll(), "Id", "Title", candidate.DesignationId); var vm = new EditCandidateViewModel(candidate); return View(vm); })); }
private void MapEditCandidate(Candidate candidate, EditCandidateViewModel model) { candidate.user_id = model.user_id; candidate.id = model.candidate_id; candidate.address_id = model.address_id; candidate.first_name = model.candidate_first_name; candidate.last_name = model.candidate_last_name; candidate.phone_number = model.candidate_phone_number; candidate.gender_id = model.gender_id; candidate.religion_id = model.religion_id; candidate.marital_status_id = model.marital_status_id; if (model.occupation != null && model.occupation != "" && model.occupation == "Other") { candidate.occupation = model.otheroccupation; } else if (model.occupation != null && model.occupation != "" && model.occupation != "Other") { candidate.occupation = model.occupation; } if (model.caste_id != null) { candidate.caste_id = (int)model.caste_id; } else { candidate.caste_id = null; } if (model.education_id != null) { candidate.education_id = (int)model.education_id; } else { candidate.education_id = null; } candidate.family_type_id = model.familytype_id; candidate.date_of_birth = model.candidate_birth_date; }
public ActionResult EditProfile(EditCandidateViewModel vm) { return(RedirectIfNotLoggedIn(() => { if (ModelState.IsValid) { var selectedCandidate = _candidateRepository.Get(vm.Id, "Person"); if (selectedCandidate != null) { selectedCandidate.RecievedOn = vm.RecievedOn; selectedCandidate.Source = vm.Source; selectedCandidate.Qualification = vm.Qualification; selectedCandidate.TotalExperience = vm.TotalExperience; selectedCandidate.ResumePath = vm.ResumePath; selectedCandidate.PhotoPath = vm.PhotoPath; selectedCandidate.Status = vm.Status; selectedCandidate.Comments = vm.Comments; selectedCandidate.CurrentCTC = vm.CurrentCTC; selectedCandidate.ExpectedCTC = vm.ExpectedCTC; selectedCandidate.DesignationId = vm.CandidateDesignationId; selectedCandidate.Person.FirstName = vm.Person.FirstName; selectedCandidate.Person.LastName = vm.Person.LastName; selectedCandidate.Person.Gender = vm.Person.Gender; selectedCandidate.Person.Email = vm.Person.Email; selectedCandidate.Person.Organization = vm.Person.Organization; selectedCandidate.Person.Designation = vm.Person.Designation; selectedCandidate.Person.PhoneNo = vm.Person.PhoneNo; selectedCandidate.Person.SecondaryEmail = vm.Person.SecondaryEmail; selectedCandidate.Person.OfficePhone = vm.Person.OfficePhone; selectedCandidate.Person.Skype = vm.Person.Skype; selectedCandidate.Person.Facebook = vm.Person.Facebook; selectedCandidate.Person.Twitter = vm.Person.Twitter; selectedCandidate.Person.GooglePlus = vm.Person.GooglePlus; selectedCandidate.Person.LinkedIn = vm.Person.LinkedIn; selectedCandidate.Person.Address = vm.Person.Address; selectedCandidate.Person.CommunicationAddress = vm.Person.CommunicationAddress; selectedCandidate.Person.DateOfBirth = vm.Person.DateOfBirth; // Clean up white spaces for Email and Phone Numbers if (!string.IsNullOrEmpty(selectedCandidate.Person.Email)) { selectedCandidate.Person.Email = selectedCandidate.Person.Email.Trim(); } if (!string.IsNullOrEmpty(selectedCandidate.Person.SecondaryEmail)) { selectedCandidate.Person.SecondaryEmail = selectedCandidate.Person.SecondaryEmail.Trim(); } if (!string.IsNullOrEmpty(selectedCandidate.Person.PhoneNo)) { selectedCandidate.Person.PhoneNo = selectedCandidate.Person.PhoneNo.Trim(); } if (!string.IsNullOrEmpty(selectedCandidate.Person.OfficePhone)) { selectedCandidate.Person.OfficePhone = selectedCandidate.Person.OfficePhone.Trim(); } // Update the Candidate Code, Fix for the existing missed candidates; selectedCandidate.Code = $"LA{selectedCandidate.Id.ToString("D" + 6)}"; _candidateRepository.Update(selectedCandidate); _unitOfWork.Commit(); // Remove the existing mapped Technologies var existingMaps = _candidateTechnologyMapRepository.GetAllBy(m => m.CandidateId == selectedCandidate.Id).ToList(); foreach (var map in existingMaps) { _candidateTechnologyMapRepository.Delete(map); } _unitOfWork.Commit(); // Map the New Technologies if (vm.TechnologyIds != null) { foreach (var technologyId in vm.TechnologyIds) { var newMap = new CandidateTechnologyMap { CandidateId = vm.Id, TechnologyId = technologyId }; _candidateTechnologyMapRepository.Create(newMap); } _unitOfWork.Commit(); } return RedirectToAction("Index"); } return RedirectToAction("Index"); } return View(vm); })); }
public IActionResult Editcandidate([FromBody] EditCandidateViewModel candidate) { return(Ok(_registrationService.Editcandidate(candidate))); }
public JsonResponse <String> Editcandidate(EditCandidateViewModel editCandidateViewModel) { JsonResponse <String> jsonResponse = new JsonResponse <String>(); var result = ValidateEditCandidate(editCandidateViewModel); if (result.IsValid) { Address candidateAddress = new Address(); Candidate candidate = new Candidate(); CandidateLanguageMap candidateLanguageMap; MapEditCandidate(candidate, editCandidateViewModel); MapEditCandidateAddress(candidateAddress, editCandidateViewModel); using (IDbConnection dbConnection = new NpgsqlConnection(_ConnectionStringService.Value)) { dbConnection.Open(); using (var transaction = dbConnection.BeginTransaction()) { try { dbConnection.Update <Address>(candidateAddress, transaction); dbConnection.Update <Candidate>(candidate, transaction); dbConnection.Query("delete from candidate_language_map where candidate_id = @p0", new { p0 = candidate.id }); for (int i = 0; i < editCandidateViewModel.language.Length; i++) { candidateLanguageMap = new CandidateLanguageMap(); candidateLanguageMap.candidate_id = candidate.id; candidateLanguageMap.language_id = editCandidateViewModel.language[i]; dbConnection.Insert <CandidateLanguageMap>(candidateLanguageMap, transaction); } transaction.Commit(); jsonResponse.Data = "Updated successfully"; jsonResponse.IsSuccess = true; jsonResponse.Message = "Candidate Updated Successful"; } catch (Exception ex) { if (ex.Message.Contains("user_table_phone_number_unique")) { jsonResponse.Message = "User phone number already exists"; } else { jsonResponse.Message = "Some error occured. Please contact administrator."; } transaction.Rollback(); jsonResponse.IsSuccess = false; } } } } else { jsonResponse.IsSuccess = false; jsonResponse.Message = result.Messages(); } return(jsonResponse); }
public EditCandidateView(CandidateViewModel editCandidate, CandidateService candidateService) : this() { _editCandidate = new EditCandidateViewModel(editCandidate, candidateService); DataContext = _editCandidate; }