コード例 #1
0
        public ActionResult Schedule(CandidateInterview interview)
        {
            interview.ValidateSchedule(ModelState, User);

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

            if (ModelState.IsValid)
            {
                if (interview.CreateAppointment())
                {
                    InterviewNotice scheduleNotice = new InterviewNotice(interview, "MeetingRequest");

                    if (TryValidateModel(scheduleNotice))
                    {
                        Mailer mailer = new Mailer(MessageTemplate.Default, true);

                        mailer.AddRecipient(interview.OrganizersEmail);
                        mailer.SendMessage("InterviewNotice", scheduleNotice, scheduleNotice.Subject);
                    }

                    InterviewNotice evaluationNotice = new InterviewNotice(interview, "Evaluation");

                    if (TryValidateModel(evaluationNotice))
                    {
                        Mailer mailer = new Mailer(MessageTemplate.Default, true);

                        mailer.AddRecipient(interview.InterviewersEmail);
                        mailer.SendMessage("InterviewNotice", evaluationNotice, evaluationNotice.Subject);
                    }

                    db.Entry(interview).State = EntityState.Modified;
                    db.SaveChanges();

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

                ModelState.AddModelError("MeetingRequest", "Meeting Request Error");
            }

            ViewBag.InterviewTypes = CandidateInterview.InterviewTypes();

            return(View(interview));
        }
コード例 #2
0
        public ActionResult Schedule(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            CandidateInterview interview = db.CandidateInterviews.Find(id);

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

            if (interview.IsRecruiter(User) == false && UserRole.IsEvalutionAdmin(User) == false)
            {
                return(View("Unauthorized"));
            }

            ViewBag.InterviewTypes = CandidateInterview.InterviewTypes();

            return(View(interview));
        }