コード例 #1
0
        public bool SendEmail(UserModel userModel, JobApplicationStatusModel model, JobOpening jobOpening)
        {
            if (model.Status == "3")
            {
                string subject = "Job Application Approved";
                string body    = "Dear " + userModel.Fullname + ",<br/><br/>Your Job Application for " + jobOpening.JobTitle + ", " + jobOpening.CompanyName + " has been approved. Your interview has been scheduled on " + model.InterviewDate.ToString("MM/dd/yyyy") + ". Further details will be communicated to your by the HR soon.<br/><br/>Regards,<br/>GyanSys";
                string to      = userModel.UserEmail;

                MailMessage mm = new MailMessage
                {
                    From = new MailAddress("*****@*****.**")
                };
                mm.To.Add(to);
                mm.Subject    = subject;
                mm.Body       = body;
                mm.IsBodyHtml = true;

                SmtpClient client = new SmtpClient("smtp.gmail.com")
                {
                    UseDefaultCredentials = false,
                    Port        = 587,
                    EnableSsl   = true,
                    Credentials = new NetworkCredential("*****@*****.**", "s/HD123gs")
                };
                client.Send(mm);

                return(true);
            }
            else
            {
                string subject = "Job Application Rejected";
                string body    = "Dear " + userModel.Fullname + ",<br/><br/>Your Job Application for " + jobOpening.JobTitle + ", " + jobOpening.CompanyName + " has been rejected. Please contact HR for help.<br/><br/>Regards,<br/>GyanSys";
                string to      = userModel.UserEmail;

                MailMessage mm = new MailMessage
                {
                    From = new MailAddress("*****@*****.**")
                };
                mm.To.Add(to);
                mm.Subject    = subject;
                mm.Body       = body;
                mm.IsBodyHtml = true;

                SmtpClient client = new SmtpClient("smtp.gmail.com")
                {
                    UseDefaultCredentials = false,
                    Port        = 587,
                    EnableSsl   = true,
                    Credentials = new NetworkCredential("*****@*****.**", "s/HD123gs")
                };
                client.Send(mm);

                return(true);
            }
        }
コード例 #2
0
ファイル: HRPortalRepo.cs プロジェクト: pratiktumul/IJPWebAPI
        // This method updates the job application status and interview date for a given job application id
        public bool UpdateJobStatus(int id, JobApplicationStatusModel model)
        {
            // Find job application details for the given id
            var jobApplication = db.JobApplications.FirstOrDefault(x => x.Id == id);

            if (jobApplication != null) // check if jobapplication is not null; if null return false
            {
                var userId = jobApplication.UserId;
                var jobId  = jobApplication.JobId;
                if (model.Status == "2") // status "2" means rejected
                {
                    jobApplication.InterviewDate = null;
                    jobApplication.Status        = Convert.ToInt32(model.Status);
                    db.SaveChanges();
                    var userDetails = db.Users.Where(x => x.UserId == userId).Select(x => new UserModel
                    {
                        UserEmail = x.UserEmail,
                        Fullname  = x.Fullname
                    }).FirstOrDefault();
                    var companyName = db.JobOpenings.FirstOrDefault(x => x.JobId == jobId);
                    //interview.SendEmail(userDetails, model, companyName);
                    return(true);
                }
                else if (model.Status == "3") // status "3" means approved
                {
                    jobApplication.InterviewDate = model.InterviewDate;
                    jobApplication.Status        = Convert.ToInt32(model.Status);
                    db.SaveChanges();
                    UpdateVacancy((int)jobApplication.JobId); // reduce job vacancy by 1
                    var userDetails = db.Users.Where(x => x.UserId == userId).Select(x => new UserModel
                    {
                        UserEmail = x.UserEmail,
                        Fullname  = x.Fullname
                    }).FirstOrDefault();
                    var companyName = db.JobOpenings.FirstOrDefault(x => x.JobId == jobId);
                    //interview.SendEmail(userDetails, model, companyName);
                    return(true);
                }
            }
            return(false);
        }
コード例 #3
0
        public IHttpActionResult UpdateJobStatus(int id, JobApplicationStatusModel model)
        {
            bool isSuccess = hRPortal.UpdateJobStatus(id, model);

            return(isSuccess ? Ok() : (IHttpActionResult)NotFound());
        }