Пример #1
0
        public async Task <ReturnWrapper <Candidate> > AssignVacancies(ICollection <int> vacIds, ICollection <int> canIds, int userId)
        {
            var candidatesToUpdate = await Task.Run(() => candidateRepository.GetCandidatesByIds(canIds));

            var vacanciesToAdd = await Task.Run(() => vacancyRepository.GetVacanciesById(vacIds));

            var events = new Dictionary <int, List <Event> >();

            foreach (var c in candidatesToUpdate)
            {
                c.LastModifier = userId;

                foreach (var v in vacanciesToAdd)
                {
                    v.LastModifier = userId;

                    if (!c.Vacancies.Contains(v))
                    {
                        c.Vacancies.Add(v);

                        var e = await eventService.RegisterCandidateToVacancyAssignment(v.Id, c.Id, userId);

                        var eventsOfUser = new List <Event>();

                        if (events.TryGetValue(v.HRM, out eventsOfUser))
                        {
                            eventsOfUser.Add(e);
                        }
                        else
                        {
                            events.Add(v.HRM, new List <Event> {
                                e
                            });
                        }

                        if (events.TryGetValue(c.HRM, out eventsOfUser))
                        {
                            eventsOfUser.Add(e);
                        }
                        else
                        {
                            events.Add(c.HRM, new List <Event> {
                                e
                            });
                        }
                    }
                }
            }

            return(new ReturnWrapper <Candidate>
            {
                Entities = candidatesToUpdate.ToList(),

                Events = events
            });
        }
Пример #2
0
        public async Task <ICollection <Vacancy> > GetVacanciesById(ICollection <int> ids)
        {
            var result = await Task.Run(() => vacancyRepository.GetVacanciesById(ids).ToList());

            return(result);
        }