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 void Should_create_new_vacancy_for_user_in_repository() { // Arrange var userId = 6; var vacancyData = new CreateVacancyDto( "Spec2", new List <String> { "Skill1", "Skill3" }, "Inform"); var expected = new VacancyDto( userId, 2, vacancyData.Specialization, vacancyData.Skills, vacancyData.Information); // Act var result = _vacancyService.CreateForUser(userId, vacancyData); // Assert Assert.That(result != null); Assert.That(result.Equals(expected)); Assert.That(result.Equals(VacancyDto.Create(_vacancyRepository.GetForUser(userId)))); }
public void Should_throw_argument_exception_when_try_to_create_vacancy_for_user_who__already_have_vacancy() { // Arrange var userId = 2; var vacancyData = new CreateVacancyDto( "Spec2", new List <String> { "Skill1", "Skill3" }, "Inform"); // Assert Assert.Throws <ArgumentException>(() => _vacancyService.CreateForUser(userId, vacancyData)); }
public VacancyDto CreateForMe(Guid token, CreateVacancyDto vacancy) { throw new NotImplementedException(); }
public VacancyDto CreateForMe(Guid token, CreateVacancyDto vacancy) { return(_vacancyClient.Create(token, vacancy).Result); }