Ejemplo n.º 1
0
        /// <summary>
        /// Adding new candidate
        /// </summary>
        /// <param name="candidate"></param>
        /// <returns></returns>
        public async Task <bool> AddCandidate(AddCandidateDto candidate)
        {
            List <Skill> skills       = _db.Skills.Where(s => candidate.Skills.Contains(s.Name)).ToList();
            Candidate    newCandidate = new Candidate
            {
                FirstName = candidate.FirstName,
                LastName  = candidate.LastName,
                Skills    = skills
            };

            List <CandidateSkill> candidateSkills = skills.Select(s => new CandidateSkill
            {
                Candidate   = newCandidate,
                CandidateId = newCandidate.Id,
                Skill       = s,
                SkillId     = s.Id
            }).ToList();

            newCandidate.CandidateSkills = candidateSkills;

            _db.Candidates.Add(newCandidate);
            await _db.SaveChangesAsync();

            return(true);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> AddCandidate(AddCandidateDto candidate)
        {
            bool result = await _candidateService.AddCandidate(candidate);

            return(Ok(result));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Adding new candidate
 /// </summary>
 /// <param name="candidate"></param>
 /// <returns></returns>
 public async Task <bool> AddCandidate(AddCandidateDto candidate)
 {
     return(await _candidateRepository.AddCandidate(candidate));
 }