Beispiel #1
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
            });
        }
Beispiel #2
0
        public ActionResult Details(int id)
        {
            var candidate = _candidateRepository.Get(id, "Person");

            if (candidate == null)
            {
                return(HttpNotFound());
            }

            ViewBag.InterviewerId = new MultiSelectList(_userRepository.GetAllBy(u => u.EmployeeStatus != EmployeeStatus.Ex && u.Id != 1, "Person"), "Id", "Person.Name");
            ViewBag.JobOpeningId  = new SelectList(_jobOpeningRepository.GetAll(), "Id", "Title");
            ViewBag.RoundId       = new SelectList(_roundRepository.GetAll(), "Id", "Title");

            var candidateDocs = _candidateDocumentRepository.GetAllBy(m => m.CandidateId == candidate.Id);
            var rounds        = _interviewRoundRepository.GetAllBy(m => m.CandidateId == candidate.Id, "Interviewer.Person,Round");

            var vm = new CandidateDetailsViewModel(candidate)
            {
                CandidateDocuments = candidateDocs.ToList(),
                InterviewRounds    = rounds.ToList()
            };

            return(View(vm));
        }