Beispiel #1
0
        public string GetAllActivitiesForCandidate(int id)
        {
            var interviews          = _interviewRoundRepository.GetAllBy(i => i.CandidateId == id).Select(i => i.Id);
            var interviewActivities = _interviewRoundActivityRepository.GetAllBy(a => interviews.Contains(a.InterviewRoundId)).Select(a => new ActivityModel()
            {
                Title     = a.Title,
                Comment   = a.Comment,
                CreatedOn = a.CreatedOn
            }).ToList();

            var activities = _candidateActivityRepository.GetAllBy(r => r.CandidateId == id, o => o.OrderByDescending(r => r.CreatedOn)).Select(a => new ActivityModel()
            {
                Title     = a.Title,
                Comment   = a.Comment,
                CreatedOn = a.CreatedOn
            }).ToList();

            interviewActivities.AddRange(activities);
            interviewActivities = interviewActivities.OrderByDescending(o => o.CreatedOn).ToList();
            var list = JsonConvert.SerializeObject(interviewActivities, Formatting.None, new JsonSerializerSettings {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            return(list);
        }
        public string GetAllActivitiesForCandidate(int id)
        {
            var activities = _candidateActivityRepository.GetAllBy(r => r.CandidateId == id, o => o.OrderByDescending(f => f.CreatedOn));
            var list       = JsonConvert.SerializeObject(activities, Formatting.None, new JsonSerializerSettings {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            return(list);
        }
Beispiel #3
0
        public OperationResult <bool> Delete(int id)
        {
            // Whether we have linked records
            var interviewRecordsExists = _interviewRoundRepository.Any(a => a.CandidateId == id);

            if (interviewRecordsExists)
            {
                return(new OperationResult <bool> {
                    Status = false, Message = "We cannot delete Candidate as we have interviews records"
                });
            }

            var jobOfferExists = _jobOfferRepository.Any(a => a.CandidateId == id);

            if (jobOfferExists)
            {
                return(new OperationResult <bool> {
                    Status = false, Message = "We cannot delete Candidate as we have Job Offer for him"
                });
            }

            // Delete all Candidate Activities
            var activities = _candidateActivityRepository.GetAllBy(m => m.CandidateId == id).ToList();

            foreach (var activity in activities)
            {
                _candidateActivityRepository.Delete(activity);
            }

            // Delete all Candidate Documents
            var docs = _candidateDocumentRepository.GetAllBy(m => m.CandidateId == id).ToList();

            foreach (var doc in docs)
            {
                _candidateDocumentRepository.Delete(doc);
            }

            // Delete all Candidate Technology Mappings
            var mappings = _candidateTechnologyMapRepository.GetAllBy(m => m.CandidateId == id).ToList();

            foreach (var mapping in mappings)
            {
                _candidateTechnologyMapRepository.Delete(mapping);
            }

            _candidateRepository.Delete(id);
            _unitOfWork.Commit();

            return(new OperationResult <bool> {
                Status = true
            });
        }