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;
 }
Example #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");
 }
Example #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;
 }
Example #7
0
 public CandidateViewModel MapToCandidateViewModel(CandidateUserModel candidateModel, string candidateName, string candidateEmail, DateTime modificationDate)
 {
     return new CandidateViewModel(candidateModel, candidateName, candidateEmail, modificationDate);
 }
 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;
 }
 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;
 }
 public async Task UpdateCandidateUserAsync(CandidateUserModel model, string candidateId)
 {
     CandidateUser candidate = _mappingService.MapToCandidateUser(model);
     candidate.ModificationDate = DateTime.UtcNow;
     await _dbService.UpdateCandidateAsync(candidate, candidateId);
 }