Пример #1
0
        public async Task <ConferenceCandidate> SubmitCandidateToConference(string confId, JobCandidate candidateDetail)
        {
            var addCandidateTask = new TaskCompletionSource <ConferenceCandidate>();
            var conference       = await _dbContext.FindAsync <Conference>(Int32.Parse(confId));

            var candidate = await _dbContext.Candidates.SingleOrDefaultAsync(c => c.BullhornCandidateId == candidateDetail.Id);

            if (candidate == null)
            {
                candidate = new Candidate {
                    BullhornCandidateId = candidateDetail.Id, FirstName = candidateDetail.FirstName, LastName = candidateDetail.LastName
                };
                await _dbContext.AddAsync <Candidate>(candidate);
            }


            var newConfCandidate = new ConferenceCandidate {
                Candidate = candidate
            };

            conference.AddCandidate(newConfCandidate);
            _dbContext.Update <Conference>(conference);
            _dbContext.SaveChanges();
            addCandidateTask.SetResult(newConfCandidate);

            return(await addCandidateTask.Task);
        }
Пример #2
0
        public async Task <ScheduleMatch> SubmitMatch(string jobId, MatchDTO match)
        {
            var addMatchTask = new TaskCompletionSource <ScheduleMatch>();
            var jobOrder     = await _dbContext.JobOrders.SingleOrDefaultAsync(j => j.BullhornJobOrderId == jobId);

            // var conference = await _dbContext.Conferences.SingleOrDefaultAsync(c => c.Id == Int32.Parse(match.ConferenceId));
            var candidate = await _dbContext.Candidates.SingleOrDefaultAsync(c => c.BullhornCandidateId == Int32.Parse(match.CandidateId));

            var conferenceCandidate = await _dbContext.ConferenceCandidates.SingleOrDefaultAsync(cc =>
                                                                                                 cc.Candidate.BullhornCandidateId == Int32.Parse(match.CandidateId) &&
                                                                                                 cc.ConferenceId == Int32.Parse(match.ConferenceId));

            var newMatch = await _dbContext.ScheduleMatches.SingleOrDefaultAsync(sm =>
                                                                                 // sm.Candidate.Candidate.Id == Int32.Parse(match.CandidateId) &&
                                                                                 // sm.Candidate.ConferenceId == Int32.Parse(match.ConferenceId));
                                                                                 sm.Candidate.Candidate.Id == conferenceCandidate.Candidate.Id &&
                                                                                 sm.Candidate.ConferenceId == conferenceCandidate.ConferenceId);

            // var newMatch = await _dbContext.JobOrders.SingleOrDefaultAsync(sm =>
            //                                                                 sm.BullhornJobOrderId == jobOrder.BullhornJobOrderId &&
            //                                                                 sm.ScheduleMatches.Contains(newMatch) .Candidate.Candidate.Id == Int32.Parse(match.CandidateId) &&
            //                                                                 sm.Candidate.ConferenceId == Int32.Parse(match.ConferenceId));

            if (conferenceCandidate == null)
            {
                conferenceCandidate = new ConferenceCandidate {
                    Candidate    = candidate,
                    ConferenceId = Int32.Parse(match.ConferenceId)
                };
            }

            if (newMatch == null)
            {
                newMatch = new ScheduleMatch
                {
                    Candidate            = conferenceCandidate,
                    TimeSlot             = match.TimeSlot,
                    Duration             = match.Duration,
                    OwnerID              = Int32.Parse(match.OwnerId),
                    InterviewerFirstName = match.InterviewerFirstName,
                    InterviewerLastName  = match.InterviewerLastName
                };
                jobOrder.AddMatch(newMatch);
            }
            //var candidate = new ConferenceCandidate { Candidate = await _dbContext.Candidates.SingleOrDefaultAsync(c => c.BullhornCandidateId == Int32.Parse(match.CandidateId)) };
            //var newMatch = new ScheduleMatch { Candidate = candidate, Duration = match.Duration, OwnerID = Int32.Parse(match.OwnerId) };

            //jobOrder.AddMatch(newMatch);
            _dbContext.Update <JobOrder>(jobOrder);
            _dbContext.SaveChanges();
            addMatchTask.SetResult(newMatch);

            return(await addMatchTask.Task);
        }
Пример #3
0
        public async Task <ScheduleMatch> DeleteMatch(string jobId, MatchDTO match)
        {
            var addMatchTask = new TaskCompletionSource <ScheduleMatch>();
            var jobOrder     = await _dbContext.JobOrders.SingleOrDefaultAsync(j => j.BullhornJobOrderId == jobId);

            //var candidate = new ConferenceCandidate { Candidate = await _dbContext.Candidates.SingleOrDefaultAsync(c => c.BullhornCandidateId == Int32.Parse(match.CandidateId)) };
            //var newMatch = new ScheduleMatch { Candidate = candidate, Duration = match.Duration, OwnerID = Int32.Parse(match.OwnerId) };
            var candidate = await _dbContext.Candidates.SingleOrDefaultAsync(c => c.BullhornCandidateId == Int32.Parse(match.CandidateId));

            var conferenceCandidate = await _dbContext.ConferenceCandidates.SingleOrDefaultAsync(cc =>
                                                                                                 cc.Candidate.BullhornCandidateId == Int32.Parse(match.CandidateId) &&
                                                                                                 cc.ConferenceId == Int32.Parse(match.ConferenceId));

            var newMatch = await _dbContext.ScheduleMatches.SingleOrDefaultAsync(sm =>
                                                                                 // sm.Candidate.Candidate.Id == Int32.Parse(match.CandidateId) &&
                                                                                 // sm.Candidate.ConferenceId == Int32.Parse(match.ConferenceId));
                                                                                 sm.Candidate.Candidate.Id == conferenceCandidate.Candidate.Id &&
                                                                                 sm.Candidate.ConferenceId == conferenceCandidate.ConferenceId);


            if (conferenceCandidate == null)
            {
                conferenceCandidate = new ConferenceCandidate
                {
                    Candidate    = candidate,
                    ConferenceId = Int32.Parse(match.ConferenceId)
                };
            }

            if (newMatch != null)
            {
                jobOrder.RemoveMatch(newMatch);
                _dbContext.Update <JobOrder>(jobOrder);
                _dbContext.SaveChanges();
                addMatchTask.SetResult(newMatch);
            }

            return(await addMatchTask.Task);
        }