public ActionResult Evaluation(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CandidateInterview interview = db.CandidateInterviews.Find(id); if (interview == null) { return(HttpNotFound()); } if (interview.IsAuthorized(User) == false && UserRole.IsEvalutionAdmin(User) == false) { return(View("Unauthorized")); } ViewBag.Grades = CandidateInterview.Grades(false); ViewBag.OptionalGrades = CandidateInterview.Grades(true); ViewBag.Recommendations = CandidateInterview.Recommendations(); if (interview.IsInterviewer(User) == false) { return(View("EvaluationReadOnly", interview)); } return(View(interview)); }
public ActionResult Evaluation(CandidateInterview interview) { interview.ValidateEvaluation(ModelState); interview.Candidate = db.Candidates.Find(interview.CandidateID); if (ModelState.IsValid) { interview.Complete = true; InterviewNotice completionNotice = new InterviewNotice(interview, "Complete"); if (TryValidateModel(completionNotice)) { Mailer mailer = new Mailer(MessageTemplate.Evaluation, true); mailer.SetFromAddress(interview.InterviewersEmail); mailer.AddRecipient(interview.OrganizersEmail); mailer.AddRecipient(interview.Candidate.RecruitersEmail); mailer.AddRecipient(interview.Candidate.ManagersEmail); mailer.SendMessage("InterviewNotice", completionNotice, completionNotice.Subject); db.Entry(interview).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details", new { id = interview.CandidateID })); } ModelState.AddModelError("MailNotice", "Mail Notice Error"); } interview.Candidate = db.Candidates.Find(interview.CandidateID); ViewBag.Grades = CandidateInterview.Grades(false); ViewBag.OptionalGrades = CandidateInterview.Grades(true); ViewBag.Recommendations = CandidateInterview.Recommendations(); return(View(interview)); }