public VacancyDto CreateForUser(Int32 userId, CreateVacancyDto vacancyData) { User user = _userRepository.Get(userId); if (user.Type != UserType.Recruiter) { throw new ArgumentException($"Unable to create recruiter for not candidate user with id {userId}!"); } if (_vacancyRepository.IsHaveForUser(userId)) { throw new ArgumentException($"Vacancy for user with id {userId} have already created!"); } var vacancy = new Vacancy( user, _specializationRepository.GetByName(vacancyData.Specialization), vacancyData.Skills .Select(s => _skillRepository.GetByName(s)) .ToList(), vacancyData.Information); vacancy = _vacancyRepository.Create(vacancy); return(VacancyDto.Create(vacancy)); }
public SummaryDto CreateForUser(Int32 userId, CreateSummaryDto summaryData) { User user = _userRepository.Get(userId); if (user.Type != UserType.Candidate) { throw new ArgumentException($"Unable to create summary for not candidate user with id {userId}!"); } if (_summaryRepository.IsHaveForUser(userId)) { throw new ArgumentException($"Summary for user with id {userId} have already created!"); } var summary = new Summary( user, _specializationRepository.GetByName(summaryData.Specialization), summaryData.Skills .Select(s => _skillRepository.GetByName(s)) .ToList(), summaryData.Information); summary = _summaryRepository.Create(summary); return(SummaryDto.Create(summary)); }