Пример #1
0
        public ActionResult AddInterview(CandidateInterview interview)
        {
            interview.ValidateInterviewer(ModelState);

            Candidate candidate = db.Candidates.Find(interview.CandidateID);

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

            CandidateNotice candidateNotice = new CandidateNotice(candidate);

            if (ModelState.IsValid)
            {
                db.CandidateInterviews.Add(interview);
                db.SaveChanges();

                candidateNotice.CandidateID = candidate.ID;

                Mailer mailer = new Mailer(MessageTemplate.Evaluation, true);

                mailer.SetFromAddress(candidate.RecruitersEmail);
                mailer.AddRecipient(candidate.RecruitersEmail);
                mailer.AddRecipient(candidate.ManagersEmail);
                mailer.AddRecipient(interview.InterviewersEmail);
                mailer.SendMessage("CandidateNotice", candidateNotice, candidateNotice.Subject);

                return(RedirectToAction("Details", new { id = interview.CandidateID }));
            }

            ViewBag.Heading = String.Format("Candidate: {0} {1}", candidate.FirstName, candidate.LastName);

            return(View(interview));
        }
Пример #2
0
        public ActionResult NewCandidate(Candidate candidate, HttpPostedFileBase file)
        {
            candidate.Validate(ModelState, User, file);

            List <CandidateInterview> interviews = candidate.Interviews.ToList();

            interviews.RemoveAll(x => String.IsNullOrWhiteSpace(x.InterviewersEmail));

            interviews.ForEach(x => x.ValidateInterviewer(ModelState));

            if (interviews.Count() == 0)
            {
                ModelState.AddModelError("InterviewersEmail", "Minimum of 1 Interviewer Required");
            }

            if (ModelState.IsValid)
            {
                candidate.SetResume(file);
                candidate.Interviews = interviews;

                CandidateNotice candidateNotice = new CandidateNotice(candidate);

                if (TryValidateModel(candidateNotice))
                {
                    db.Candidates.Add(candidate);
                    db.SaveChanges();

                    candidateNotice.CandidateID = candidate.ID;

                    Mailer mailer = new Mailer(MessageTemplate.Evaluation, true);

                    mailer.SetFromAddress(candidate.RecruitersEmail);
                    mailer.AddRecipient(candidate.RecruitersEmail);
                    mailer.AddRecipient(candidate.ManagersEmail);
                    candidate.Interviews.ToList().ForEach(x => mailer.AddRecipient(x.InterviewersEmail));
                    mailer.SendMessage("CandidateNotice", candidateNotice, candidateNotice.Subject);

                    return(RedirectToAction("Index"));
                }

                ModelState.AddModelError("MailNotice", "Mail Notice Error");
            }

            return(View(candidate));
        }
Пример #3
0
 public ActionResult CandidateNotice(CandidateNotice candidateNotice)
 {
     return(View(candidateNotice));
 }