Exemple #1
0
        private bool ValidateData(CandidateModel candidate, DefaultViewModel model)
        {
            if (string.IsNullOrWhiteSpace(candidate.FirstName) ||
                string.IsNullOrWhiteSpace(candidate.LastName) ||
                string.IsNullOrWhiteSpace(candidate.Address) ||
                candidate.Skills.Count == 0)
            {
                model.ErrorMessages.Add("Every field is mandatory");
                return false;
            }

            return true;
        }
Exemple #2
0
 public async Task SaveCandidateDataAsync(CandidateModel model)
 {
     var candidate = new Candidate
     {
         FirstName = model.FirstName,
         LastName = model.LastName,
         Address = model.Address,
         Created = DateTime.Now
     };
     foreach (var skill in model.Skills)
     {
         candidate.CandidateSkills.Add(new CandidateSkill { Candidate = candidate, Skill = skill });
     }
     _context.Candidates.Add(candidate);
     await _context.SaveChangesAsync();
 }