Exemplo n.º 1
0
        public ActionResult SendReminder(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)
            {
                return(View("Unauthorized"));
            }

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

            InterviewNotice pastDueNotice = new InterviewNotice(interview, "PastDue");

            if (pastDueNotice != null)
            {
                Mailer mailer = new Mailer(MessageTemplate.Default, true);

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

                return(Content(String.Format("Reminder has been sent to {0}", interview.InterviewersName)));
            }

            return(Content("Failed to send reminder"));
        }
Exemplo n.º 2
0
        public IHttpActionResult SendEvaluationPastDueNotice(CandidateInterview interview)
        {
            try
            {
                interview.Candidate = db.Candidates.Find(interview.CandidateID);

                InterviewNotice pastDueNotice = new InterviewNotice(interview, "PastDue");

                if (pastDueNotice != null)
                {
                    Mailer mailer = new Mailer(MessageTemplate.Default, true);

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

                    return(StatusCode(HttpStatusCode.NoContent));
                }

                return(BadRequest());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
Exemplo n.º 3
0
        public ActionResult CancelReminder(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 && interview.IsOrganizer(User) == false)
            {
                return(View("Unauthorized"));
            }

            try
            {
                interview.Complete = true;

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

                return(RedirectToAction("PastDue"));
            }
            catch (Exception)
            {
                return(Content("Failed to cancel reminders"));
            }
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
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));
        }
        public JsonResult SetInterviewDate([FromBody] Interview data)
        {
            var msg = new JMessage()
            {
                Error = true
            };

            try
            {
                if (data == null)
                {
                    msg.Title = "Chọn ngày phỏng vấn!";
                    return(Json(msg));
                }

                if (string.IsNullOrEmpty(data.CandidateCode))
                {
                    msg.Title = "Chọn mã candidate!";
                    return(Json(msg));
                }


                var query = _context.CandidateInterviews.Where(x => x.CandidateCode.Equals(data.CandidateCode));
                if (query.Count() > 0)
                {
                    var a = _context.CandidateInterviews.FirstOrDefault(x => x.CandidateCode.Equals(data.CandidateCode));
                    a.InterviewDate = data.InterviewDate;
                    _context.CandidateInterviews.Update(a);
                    _context.SaveChanges();

                    msg.Error = false;
                    msg.Title = "Cập nhật lịch thành công";

                    return(Json(msg));
                }

                CandidateInterview obj = new CandidateInterview()
                {
                    CandidateCode = data.CandidateCode,
                    //InterviewDate = DateTime.ParseExact(data.InterviewDate.Replace(' ', 'T'), "dd/MM/yyyy", CultureInfo.InvariantCulture)
                    InterviewDate = data.InterviewDate
                };

                _context.CandidateInterviews.Add(obj);
                _context.SaveChanges();

                msg.Error = false;
                msg.Title = "Cập nhật thành công!";
                return(Json(msg));
            }
            catch (Exception ex)
            {
                msg.Object = ex;
                msg.Title  = "Có lỗi xảy ra!";
                return(Json(msg));

                throw;
            }
        }
Exemplo n.º 7
0
        public int Add(CandidateInterview candidateInterview)
        {
            _ctx.CandidateInterviews.Add(candidateInterview);
            _ctx.SaveChanges();
            var candidateInterviewId = candidateInterview.Id;

            return(candidateInterviewId);
        }
Exemplo n.º 8
0
        public ActionResult CancelInterviewConfirmed(int id)
        {
            CandidateInterview interview = db.CandidateInterviews.Find(id);

            db.CandidateInterviews.Remove(interview);
            db.SaveChanges();

            return(RedirectToAction("Unscheduled"));
        }
Exemplo n.º 9
0
        public ActionResult CancelInterview(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

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

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

            return(View(interview));
        }
Exemplo n.º 10
0
        public IHttpActionResult PutInterview(int id, dynamic psObject)
        {
            try
            {
                CandidateInterview interview = db.CandidateInterviews.Find(id);

                interview.UpdateFromDynamicObject(psObject);

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

                return(StatusCode(HttpStatusCode.NoContent));
            }
            catch
            {
                return(BadRequest());
            }
        }
Exemplo n.º 11
0
        public InterviewNotice(CandidateInterview interview, string noticeType)
        {
            NoticeType  = noticeType;
            InterviewID = interview.ID;
            CandidateID = interview.CandidateID;
            Candidate   = interview.Candidate.Name;
            Organizer   = interview.OrganizersName;

            if (interview.InterviewDate != null)
            {
                InterviewDate = Convert.ToDateTime(interview.InterviewDate).ToString("MMMM dd, yyyy");
            }

            switch (NoticeType)
            {
            case "Appointment":
                Heading = "New Interview Appointment";
                Subject = String.Format("{0} Interview ({1}): {2} with {3}", interview.InterviewType, interview.Candidate.Title, interview.InterviewersName, interview.Candidate.Name);
                break;

            case "MeetingRequest":
                Heading = "New Interview Meeting Request";
                Subject = String.Format("Meeting Request has been created for {0}", interview.Candidate.Name);
                break;

            case "Evaluation":
                Heading = "Interview Evaluation";
                Subject = String.Format("Interview Evaluation for {0}", interview.Candidate.Name);
                break;

            case "PastDue":
                Heading = "Interview Evaluation Past Due";
                Subject = String.Format("Interview Evaluation for {0} is Past Due", interview.Candidate.Name);
                break;

            case "Complete":
                Heading = "Interview Evaluation Complete";
                Subject = String.Format("Interview Evaluation for {0} is Complete", interview.Candidate.Name);
                break;

            default:
                break;
            }
        }
Exemplo n.º 12
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));
        }
Exemplo n.º 13
0
        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));
        }
Exemplo n.º 14
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));
        }