예제 #1
0
 public CandidateViewModel(CandidateUserModel candidate, string name, string email, DateTime modificationDate)
 {
     Candidate = candidate;
     Name = name;
     Email = email;
     ModificationDate = modificationDate.ToLocalTime();
 }
 public void AddNoSkillMessageIfNeeded(CandidateUserModel model)
 {
     if (!model.HasSkills())
     {
         ModelState.AddModelError("NoSkillMessage", "Add at least one skill to get access to 'Best offers'");
     }
 }
 private bool ValidateForm(CandidateUserModel model)
 {
     if (ModelState.IsValid) 
     {
         ValidateSkills(model.Skills);
     }
     return ModelState.IsValid;
 }
예제 #4
0
 public CandidateUser MapToCandidateUser(CandidateUserModel candidateModel)
 {
     var skills = MapSkillModelsToSkills(candidateModel.Skills);
     var candidate = new CandidateUser()
     {
         ExperienceDescription = candidateModel.ExperienceDescription,
         ExperienceInYears = candidateModel.ExperienceInYears,
         Salary = candidateModel.Salary,
         Skills = skills,
     };
     return candidate;
 }
 public async Task<ActionResult> Index(CandidateUserModel model)
 {
     if (_authenticationService.IsCandidate(Request))
     {
         var currentUserId = _authenticationService.GetUserIdFromRequest(Request);
         if (ValidateForm(model))
         {
             await _applicationService.UpdateCandidateUserAsync(model, currentUserId);
             var updatedViewModel = await _applicationService.GetCandidateViewModelByIdAsync(currentUserId);
             return View(updatedViewModel);
         }
         var viewModel = await _applicationService.GetCandidateViewModelByIdAsync(model, currentUserId);
         return View(viewModel);
     }
     return RedirectToAction("DeniedPermission", "Home");
 }
예제 #6
0
 public CandidateUserModel MapToCandidateUserModel(CandidateUser candidate)
 {
     var skillModels = MapSkillsToSkillModels(candidate.Skills);
     var candidateModel = new CandidateUserModel(candidate.Salary, candidate.ExperienceDescription, candidate.ExperienceInYears, skillModels);
     return candidateModel;
 }
예제 #7
0
 public CandidateViewModel MapToCandidateViewModel(CandidateUserModel candidateModel, string candidateName, string candidateEmail, DateTime modificationDate)
 {
     return new CandidateViewModel(candidateModel, candidateName, candidateEmail, modificationDate);
 }
예제 #8
0
 public async Task<ScoredOfferListViewModel> GetOffersSortedByScoreAsync(CandidateUserModel candidateModel)
 {
     var offerList = await _dbService.GetAllOffersListAsync();
     var skills = _mappingService.MapSkillModelsToSkills(candidateModel.Skills);
     var scoredOfferViewModelList = GetScoredOffersViewModel(skills, offerList);
     var sortedScoredOffersViewModel = scoredOfferViewModelList.OrderByDescending(r => r.Offer.Score).ToList();
     var scoredOfferListViewModel = _mappingService.MapToScoredOfferListViewModel(sortedScoredOffersViewModel);
     return scoredOfferListViewModel;
 }
예제 #9
0
 public async Task<CandidateViewModel> GetCandidateViewModelByIdAsync(CandidateUserModel candidateModel, string candidateId)
 {
     var candidate = await _dbService.GetCandidateByIdAsync(candidateId);
     var candiateViewModel = _mappingService.MapToCandidateViewModel(candidateModel, candidate.Name, candidate.Email, candidate.ModificationDate);
     return candiateViewModel;
 }
예제 #10
0
 public async Task UpdateCandidateUserAsync(CandidateUserModel model, string candidateId)
 {
     CandidateUser candidate = _mappingService.MapToCandidateUser(model);
     candidate.ModificationDate = DateTime.UtcNow;
     await _dbService.UpdateCandidateAsync(candidate, candidateId);
 }