Пример #1
0
        public bool CreateScreeningQuestions(int screeningId, string userEmail, List <ScreeningQuestionsModel> lstScreeningQuestionsModel)
        {
            try
            {
                var screening = this.context.Screening.Include(sc => sc.ScreeningCandidate).Include(sq => sq.ScreeningQuestions).Where(x => x.ScreeningId == screeningId).FirstOrDefault();

                screening.LastUpdated    = DateTime.Now;
                screening.LastUpdatedBy  = userEmail;
                screening.ReviewerStatus = EnumScreeningStatus.Screening_Invitation_Sent.ToString();
                screening.AdminStatus    = EnumScreeningStatus.Screening_Invitation_Sent.ToString();
                screening.Status         = EnumScreeningStatus.In_Process.ToString();

                foreach (var candidate in screening.ScreeningCandidate)
                {
                    candidate.ScreeningStatus     = EnumScreeningStatus.Awaiting_Candidate_Response.ToString();
                    candidate.LastUpdated         = DateTime.Now;
                    candidate.LastUpdatedBy       = userEmail;
                    candidate.CandidateSignInCode = Guid.NewGuid().ToString();
                }

                screening.ScreeningQuestions = this._mapper.Map(lstScreeningQuestionsModel, new List <ScreeningQuestions>());

                this.context.Screening.Update(screening);
                Save();

                //Send  email to candidates

                foreach (var candidate in screening.ScreeningCandidate)
                {
                    var sendGridMessage = new SendGridMessage();
                    sendGridMessage.SetSubject("Video Interview Request From " + screening.HiringCompanyName);
                    sendGridMessage.AddTo(candidate.CandidateEmail);
                    sendGridMessage.SetFrom(new EmailAddress("*****@*****.**", "TechScreen360"));

                    sendGridMessage.AddContent(MimeType.Html,
                                               "Dear " + candidate.CandidateFirstName + " " + candidate.CandidateLastName + ", " +
                                               "<br><br>" +
                                               "Congratulations ! You have received Video Interview Request from  <b>" + screening.HiringCompanyName + " .</b><br><br>" +
                                               "Please follow below instructions to complete your video interview:<br><br>" +
                                               "1. This is a video interview so make sure to test your laptop's webcam and audio device is working fine." +
                                               "<br><br>" +
                                               "2. For the best results, please use latest <b>Google Chrome Browser.</b>" +
                                               "<br><br>" +
                                               "3. Click on the following link : <b> https://www.techscreen360.com/jobapplicant</b>" +
                                               "<br><br>" +
                                               " <b>Your sign in Code is :</b> " + candidate.CandidateSignInCode +
                                               "<br><br>" +
                                               "The sign in code will expire 48 hours after you receive this email." +
                                               "<br><br>" +
                                               "Best of luck for your interview. " +
                                               "<br><br>" +
                                               "If you come across any issue, please contact [email protected]" +
                                               "<br><br><br>" +
                                               "Regards," +
                                               "<br>" +
                                               "TechScreen360 InterviewSupport"

                                               );

                    EmailUtility.SendGridMessage(sendGridMessage).Wait();
                }


                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }