public ActionResult EditResponseStatus(int?applicantId, ApplicationFormResponseStatus status)
        {
            if (applicantId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var formResponse = _formResponsesDataAccess.GetResponseByApplicantId(applicantId);

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

            _formResponsesDataAccess.EditResponseStatus(formResponse, status);

            var applicant = _applicantsDataAccess.GetApplicantById(applicantId);

            if (status == ApplicationFormResponseStatus.Passed)
            {
                _applicantsDataAccess.EditApplicantStatus(applicant, ApplicantStatus.ScreeningPassed);
            }
            else if (status == ApplicationFormResponseStatus.NotPassed)
            {
                _applicantsDataAccess.EditApplicantStatus(applicant, ApplicantStatus.ScreeningRejected);
            }
            else
            {
                _applicantsDataAccess.EditApplicantStatus(applicant, ApplicantStatus.ApplicationSubmitted);
            }

            return(RedirectToAction("Index", "Applicants"));
        }
        public ActionResult Save(PhoneInterviewViewModel phoneInterviewViewModel)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.ErrorMsg = "Failed to create Phone Interview. Check the correctness of your input format";
                return(View("Error"));
            }

            phoneInterviewViewModel.PhoneInterview.SubmissionDate = DateTime.Now;
            _phoneInterviewDataAccess.CreatePhoneInterview(phoneInterviewViewModel.PhoneInterview);

            var applicant = _applicantsDataAccess.GetApplicantById(phoneInterviewViewModel.PhoneInterview.ApplicantId);

            if (phoneInterviewViewModel.PhoneInterview.Status == PhoneIntervewStatus.Passed)
            {
                _applicantsDataAccess.EditApplicantStatus(applicant, ApplicantStatus.PhoneInterviewPassed);
            }
            else if (phoneInterviewViewModel.PhoneInterview.Status == PhoneIntervewStatus.NotPassed)
            {
                _applicantsDataAccess.EditApplicantStatus(applicant, ApplicantStatus.PhoneInterviewRejected);
            }

            return(RedirectToAction("Index", "Applicants"));
        }
        public ActionResult SaveFeedback(FeedbackFormViewModel feedbackFormViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("Error"));
            }

            var interview = feedbackFormViewModel.Feedback.Interview;

            feedbackFormViewModel.Feedback.Interview = null;

            feedbackFormViewModel.Feedback.SubmissionDate = DateTime.Now;
            _feedbacksDataAccess.CreateFeedback(feedbackFormViewModel.Feedback);

            var applicant = _applicantsDataAccess.GetApplicantById(interview.ApplicantId);

            if (interview.InterviewType == InterviewType.HR)
            {
                if (feedbackFormViewModel.Feedback.Hired)
                {
                    _applicantsDataAccess.EditApplicantStatus(applicant, ApplicantStatus.HRPassed);
                }
                else
                {
                    _applicantsDataAccess.EditApplicantStatus(applicant, ApplicantStatus.HRRejected);
                }
            }
            else if (interview.InterviewType == InterviewType.Technical)
            {
                if (feedbackFormViewModel.Feedback.Hired)
                {
                    _applicantsDataAccess.EditApplicantStatus(applicant, ApplicantStatus.TechPassed);
                }
                else
                {
                    _applicantsDataAccess.EditApplicantStatus(applicant, ApplicantStatus.TechRejected);
                }
            }
            else if (interview.InterviewType == InterviewType.HiringManager)
            {
                if (feedbackFormViewModel.Feedback.Hired)
                {
                    _applicantsDataAccess.EditApplicantStatus(applicant, ApplicantStatus.HiringManagerAccepted);
                }
                else
                {
                    _applicantsDataAccess.EditApplicantStatus(applicant, ApplicantStatus.HiringManagerRejected);
                }
            }

            return(RedirectToAction("Details", new { applicantId = interview.ApplicantId, interviewType = interview.InterviewType }));
        }