Esempio n. 1
0
        public static CandidateComment CandidateToCandidateComment(Candidate candidate, IDataRepository dataRepository)
        {
            var candidateComment = new CandidateComment()
            {
                Id         = candidate.Id,
                Age        = candidate.Age,
                Email      = candidate.Email,
                Experience = candidate.Experience,
                FullName   = candidate.FullName,
                GenderId   = candidate.GenderId,
                JobStateId = candidate.JobStateId,
                Phone      = candidate.Phone,
                Position   = candidate.Position,
                //ProjectId = candidate.ProjectId,
                //TechStackId = candidate.TechStackId,
                JobState        = dataRepository.GetNameById(nameof(JobState), candidate.GenderId),
                Gender          = dataRepository.GetNameById(nameof(Gender), candidate.GenderId),
                Project         = dataRepository.GetNameById(nameof(Project), candidate.ProjectId),
                TechStack       = dataRepository.GetNameById(nameof(TechStack), candidate.TechStackId),
                ResidentAddress = candidate.ResidentAddress,
                ResumePath      = candidate.ResumePath,
            };

            return(candidateComment);
        }
Esempio n. 2
0
        public IActionResult CandidateComment(int Id)
        {
            var candidate        = _dataRepository.GetCandidate(Id);
            var candidateComment = new CandidateComment();

            if (candidate != null)
            {
                candidateComment = ConvertModel.CandidateToCandidateComment(candidate, _dataRepository);
            }

            var comments = _dataRepository.GetComments(Id);

            if (comments.Any())
            {
                var hrRoleId      = _dataRepository.GetIdByName(nameof(Role), ConstStrings.HR);
                var interviewerId = _dataRepository.GetIdByName(nameof(Role), ConstStrings.Interviewer);
                var pmId          = _dataRepository.GetIdByName(nameof(Role), ConstStrings.PM);
                var clientId      = _dataRepository.GetIdByName(nameof(Role), ConstStrings.Client);

                candidateComment.InterviewComments = new InterviewComments()
                {
                    HRComment     = _dataRepository.GetComment(comments, Id, hrRoleId),
                    PMComment     = _dataRepository.GetComment(comments, Id, pmId),
                    ClientComment = _dataRepository.GetComment(comments, Id, clientId),
                };

                // Interviewer Comment
                var interviewerJson = _dataRepository.GetComment(comments, Id, interviewerId);
                if (!string.IsNullOrWhiteSpace(interviewerJson))
                {
                    var interviewerComments = JsonSerializer.Deserialize <InterviewerComments>(interviewerJson);
                    candidateComment.InterviewComments.InterviewerComments = interviewerComments;
                }
            }

            return(View(candidateComment));
        }
Esempio n. 3
0
 public IActionResult SaveComment(CandidateComment candidateComment)
 {
     _dataRepository.SaveComment(candidateComment);
     return(RedirectToAction("CandidateComment", new { id = candidateComment.Id }));
 }
Esempio n. 4
0
        public CandidateComment SaveComment(CandidateComment candidateComment)
        {
            var exitComments = context.Comments.Where(a => a.CandidateId == candidateComment.Id);

            context.Comments.RemoveRange(exitComments);
            context.SaveChanges();

            var interViewComment = candidateComment.InterviewComments;
            var comments         = new List <Comment>();

            // HR comment
            var hrComment = interViewComment.HRComment;

            if (!string.IsNullOrWhiteSpace(hrComment))
            {
                comments.Add(new Comment()
                {
                    CandidateId = candidateComment.Id,
                    RoleId      = GetIdByName(nameof(Role), ConstStrings.HR),
                    Text        = hrComment
                });
            }

            // Interviewer comment
            var interviewerComments = interViewComment.InterviewerComments;

            if (GenericMethod.IsStringOrIntPropertiesHasValue(interviewerComments))
            {
                comments.Add(new Comment()
                {
                    CandidateId = candidateComment.Id,
                    RoleId      = GetIdByName(nameof(Role), ConstStrings.Interviewer),
                    Text        = JsonSerializer.Serialize(interviewerComments)
                });
            }
            // PM comment
            var pmComment = interViewComment.PMComment;

            if (!string.IsNullOrWhiteSpace(pmComment))
            {
                comments.Add(new Comment()
                {
                    CandidateId = candidateComment.Id,
                    RoleId      = GetIdByName(nameof(Role), ConstStrings.PM),
                    Text        = pmComment
                });
            }

            // Client comment
            var clientComment = interViewComment.ClientComment;

            if (!string.IsNullOrWhiteSpace(clientComment))
            {
                comments.Add(new Comment()
                {
                    CandidateId = candidateComment.Id,
                    RoleId      = GetIdByName(nameof(Role), ConstStrings.Client),
                    Text        = clientComment
                });
            }

            context.Comments.AddRange(comments);
            context.SaveChanges();
            return(candidateComment);
        }