public List <VacancyDto> Get() { return(_vacancyRepository .Get() .Select(VacancyDto.Create) .ToList()); }
public async Task <IActionResult> Get() { var vacancies = await _repo.Get(); var vacanciesDto = _mapper.Map <IList <VacancyDTO> >(vacancies); return(Ok(vacanciesDto)); }
public void Should_delete_vacancy_by_id_from_repository() { // Arrange var vacancyId = 0; var expected = _vacancyService.Get(vacancyId); // Act var result = _vacancyService.Delete(vacancyId); // Assert Assert.That(result.Equals(expected)); Assert.Throws <ArgumentException>(() => _vacancyRepository.Get(vacancyId)); }
public async Task <IActionResult> ToggleEnable(int?id) { var vacancy = await _vacancyRepository.Get(id ?? 0); if (vacancy == null) { return(NotFound()); } vacancy.Enabled = !vacancy.Enabled; await _vacancyRepository.Update(vacancy); return(RedirectToAction(nameof(Index))); }
public UpdateVacancyValidator( IVacancyRepository vacancyRepository, IComponentContext componentContext) { Guard.AgainstNullArgument(nameof(vacancyRepository), vacancyRepository); Guard.AgainstNullArgument(nameof(componentContext), componentContext); RuleFor(m => m.Vacancy).NotNull() .WithMessage(Messages.NotNull) .DependentRules(() => { RuleFor(m => m.Vacancy.Id).NotNull() .WithMessage(Messages.NotNull) .DependentRules(() => { RuleFor(m => m.Vacancy.Id) .MustAsync((id, token) => vacancyRepository.Exists(id.Value)) .WithMessage("Вакансии с id '{PropertyValue}' не существует."); RuleFor(m => m.Vacancy) .MustAsync(async(vacancy, token) => (await vacancyRepository.GetStatus(vacancy.Id.Value)) == VacancyStatusEntity.Draft) .WithMessage("Для изменения вакансия должна быть черновиком.") .MustAsync(async(vacancy, token) => (await vacancyRepository.Get(vacancy.Id.Value)).JobPositionId == vacancy.JobPositionId) .WithMessage("Нельзя изменять должность вакансии."); ; }); RuleFor(m => m.Vacancy) .SetValidator(componentContext.Resolve <VacancyValidator>()); }); }
public async Task Handle(UpdateVacancy request) { var vacancy = await _vacancyRepository.Get(request.Vacancy.Id.Value); vacancy.Update(request.Vacancy); await _unitOfWork.SaveChangesAsync(); }
public async Task Handle(OpenVacancy request) { var vacancy = await _vacancyRepository.Get(request.VacancyId.Value); vacancy.Status = VacancyStatusEntity.Opened; await _unitOfWork.SaveChangesAsync(); }
public async Task <GetVacancyResult> Handle(GetVacancy query) { var vacancy = await _vacancyRepository.Get(query.VacancyId.Value); return(new GetVacancyResult { Title = vacancy.JobPosition.Title, Description = vacancy.Form.Description, QuestionsCount = vacancy.Form.Questions.Count }); }
public void Should_create_suggestions_for_user_when_it_have_not_in_repository() { // Arrange var compiler = new VacancyCompiler(); var expected = compiler.Compile(_vacancyRepository.Get(), _rule); // Act var result = _vacancySuggestionService.SuggestAllForUser(0); // Assert Assert.That(result, Is.Not.Null); Assert.That(result.Count, Is.EqualTo(expected.Count())); Assert.That(result.Select(s => s.Vacancy.Id), Is.EquivalentTo(expected.Select(s => s.Id))); }
public void UpdateMatch(Int32 summaryId, Int32 vacancyId) { Match match = _matchRepository.GetAllForSummary(summaryId).FirstOrDefault(m => m.Vacancy.Id == vacancyId); if (match is null) { var summary = _summaryRepository.Get(summaryId); var vacancy = _vacancyRepository.Get(vacancyId); _matchRepository.Add(new Match(summary, vacancy)); } else { match.Update(); _matchRepository.Update(match); } }
private IEnumerable <SummarySuggestion> CompileForVacancy(Int32 vacancyId) { Vacancy vacancy = _vacancyRepository.Get(vacancyId); var compiler = new SummaryCompiler(); var rule = new SimpleSummaryRule(vacancy.Specialization, vacancy.Skills); IEnumerable <Summary> summaries = compiler.Compile(_summaryRepository.Get(), rule); IReadOnlyCollection <SummarySuggestion> summarySuggestions = summaries.Select(s => new SummarySuggestion(vacancy, s)).ToList(); summarySuggestions = _summarySuggestionRepository.Add(summarySuggestions).ToList(); if (!summarySuggestions.Any()) { throw new ArgumentException("It's no suggestion for vacancy! Change vacancy or try later."); } return(summarySuggestions); }
public async Task Handle(StartInterview request) { var interview = await _interviewRepository.Get(request.InterviewId.Value); var vacancy = await _vacancyRepository.Get(interview.VacancyId); interview.Status = InterviewStatusEntity.Started; interview.FormSagaEntity = new FormSagaEntity { Questions = vacancy.Form.Questions .Select(question => { QuestionSagaEntity saga; switch (question) { case InputQuestionEntity input: saga = new InputQuestionSagaEntity(); break; case SelectQuestionEntity select: saga = new SelectQuestionSagaEntity(); break; case GeneralQuestionEntity general: saga = new GeneralQuestionSagaEntity(); break; default: throw new InvalidOperationException($"Can't convert '{question.GetType().FullName}'"); } saga.QuestionId = question.Id; saga.Status = QuestionSagaStatusEntity.NotStarted; return(saga); }) .ToList() }; await _unitOfWork.SaveChangesAsync(); } }
private IEnumerable <VacancySuggestion> CompileForSummary(Int32 summaryId) { Summary summary = _summaryRepository.Get(summaryId); var compiler = new VacancyCompiler(); var rule = new SimpleVacancyRule(summary.Specialization, summary.Skills); IEnumerable <Vacancy> summaries = compiler.Compile(_vacancyRepository.Get(), rule); IReadOnlyCollection <VacancySuggestion> vacancySuggestions = summaries.Select(s => new VacancySuggestion(summary, s)).ToList(); vacancySuggestions = _vacancySuggestionRepository.Add(vacancySuggestions).ToList(); if (!vacancySuggestions.Any()) { throw new ArgumentException("It's no suggestion for summary! Change summary or try later."); } return(vacancySuggestions); }
public async Task <GetVacancyResult> Handle(GetVacancy query) { var entity = await _vacancyRepository.Get(query.VacancyId.Value); return(new GetVacancyResult { Vacancy = new Vacancy { Id = entity.Id, CandidateRequirements = entity.CandidateRequirements, JobPositionId = entity.JobPositionId, JobsNumber = entity.JobsNumber, Salary = entity.Salary, TeamId = entity.TeamId, Form = new Form { Description = entity.Form.Description, Questions = entity.Form.Questions.Select(q => q.CreateContractQuestion()) .ToArray() }, Status = entity.Status.CreateContract() } }); }
public async Task <ActionResult <ICollection <VacancyDto> > > Index() { return(Ok(await _repository.Get())); }
public Vacancy Get(Guid vacancyId) { return(_vacancyRepository.Get(vacancyId)); }
public Vacancy Get(int itemId) { return(VacancyRepository.Get().FirstOrDefault(x => x.VacancyId == itemId)); }