public void DeleteInterview([FromBody] InterviewInfoData data)
        {
            var tokenString = Request.Headers["Authorization"];
            var token       = new TokenData(tokenString);

            if (!AuthManager.ValidateAuthToken(token))
            {
                Response.StatusCode = (int)HttpStatusCode.NetworkAuthenticationRequired;
                return;
            }
            if (!UsersManager.GetUser(token).HasRoot(RootEnum.Manager))
            {
                Response.StatusCode = (int)HttpStatusCode.Forbidden;
                return;
            }

            InterviewManager.DeleteInterview(data);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Delete interview with the same parameters as was passed
        /// </summary>
        /// <param name="info">Consists of candidate id, interview id and also time of interview</param>
        /// <exception cref="InterviewerDoesntExistsException">if interviewer id doesn't exists</exception>
        /// <exception cref="CandidateDoesntExistsException">if candidate id doesn't exists</exception>
        public static void DeleteInterview(InterviewInfoData info)
        {
            if (!UsersManager.IsUserExists <CandidateUser>(info.CandidateID))
            {
                throw new CandidateDoesntExistsException(info.CandidateID);
            }

            if (!UsersManager.IsUserExists <InterviewerUser>(info.InterviewerID))
            {
                throw new InterviewerDoesntExistsException(info.InterviewerID);
            }


            if (!Instance._interviews.Remove(info))
            {
                return;
            }

            UsersManager.GetUser <CandidateUser>(info.CandidateID).Status = WaitingInterview;
            Instance._readyCandidates.Add(info.CandidateID);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create interview with such Interview Info
        /// </summary>
        /// <param name="info">Consists of candidate id, interview id and also time of interview</param>
        /// <exception cref="CandidateNotReadyForInterviewException">if candidate isn't ready for interview</exception>
        /// <exception cref="InterviewerDoesntExistsException">if interviewer id doesn't exists</exception>
        /// <exception cref="CandidateDoesntExistsException">if candidate id doesn't exists</exception>
        public static void CreateInterview(InterviewInfoData info)
        {
            if (!UsersManager.IsUserExists <CandidateUser>(info.CandidateID))
            {
                throw new CandidateDoesntExistsException(info.CandidateID);
            }

            if (!UsersManager.IsUserExists <InterviewerUser>(info.InterviewerID))
            {
                throw new InterviewerDoesntExistsException(info.InterviewerID);
            }

            if (Instance._readyCandidates.Any(n => n == info.CandidateID))
            {
                UsersManager.GetUser <CandidateUser>(info.CandidateID).Status =
                    PassingInterview;

                Instance._interviews.Add(info);
                Instance._readyCandidates.Remove(info.CandidateID);
            }
            else
            {
                if (UsersManager.GetUser <CandidateUser>(info.CandidateID).Status ==
                    WaitingInterview)
                {
                    UsersManager.GetUser <CandidateUser>(info.CandidateID).Status =
                        PassingInterview;

                    Instance._interviews.Add(info);
                }
                else
                {
                    throw new CandidateNotReadyForInterviewException(info.CandidateID);
                }
            }
        }