public EmployersJobApplicationsViewModel(JobApplication entity)
 { 
         id = entity.Id;
         // currently it includes both name and email
         applicant = entity.ApplicantEmail;
         dateCreated = entity.DateCreated;
         jobTitle = entity.JobPost.JobTitle;
         salaryNote = entity.JobPost.SalaryNote;
         jobPostId = entity.JobPost.Id;
 }
Пример #2
0
        public JobApplicationViewModel(JobApplication entity)
        { 
                id = entity.Id;
                email = entity.ApplicantEmail;
                skills = entity.ApplicantSkills;
                experience = entity.ApplicantExperience;
                message = entity.ApplicantMessage;
                dateCreated = entity.DateCreated;

                idealJobTitle = entity.JobPost.JobTitle;
                idealLocation = entity.JobPost.Location;
                idealSalary = entity.JobPost.SalaryNote;
        }
Пример #3
0
        private bool IsJobApplicationsLimitReached(Models.User user, JobApplication entity)
        {
            // tODO restrict anonymous users as well
            if (user == null)
                return false;
            var sameApplications = user.jobApplications.Where(ja => ja.JobPost.Id == entity.JobPost.Id);

            // check if already applied for this same job
            var isAllowed= true;
            if (sameApplications.Count() > 1)
                isAllowed = false;

            // check if reached a limit of job applications per day
            var todaysApplications = user.jobApplications.Where(ja => ja.DateCreated.DayOfYear == DateTime.UtcNow.DayOfYear && ja.DateCreated.Year == DateTime.UtcNow.Year);
            if (todaysApplications.Count() > 30)
                isAllowed = false;

            return !isAllowed;
        }
Пример #4
0
        public static void NotifyRecruiter(Models.JobApplication entity, string cvFolder)
        {
            // Save in Mails folder for sending later

            //E:\Work\AngJobs.com\src\Angjobs\Angjobs\Assets\bootstrap\css\bootstrap-theme.css
            //E:\Work\AngJobs.com\src\Angjobs\Angjobs\Assets\bootstrap\css\bootstrap.min.css
            //E:\Work\AngJobs.com\src\Angjobs\Angjobs\Assets\styles\styles.css
            var template = new StringBuilder();

            template.AppendLine(@"<html>");
            template.AppendLine(@"<style>");

            template.AppendLine(@"     .bg-light {                  ");
            template.AppendLine(@"    color: #58666e;               ");
            template.AppendLine(@"    background-color: #edf1f2;    ");
            template.AppendLine(@"    }                             ");
            template.AppendLine(@"    .label {                      ");
            template.AppendLine(@"        display: inline;          ");
            template.AppendLine(@"        padding: .2em .6em .3em;  ");
            template.AppendLine(@"        font-size: 75%;           ");
            template.AppendLine(@"        font-weight: bold;        ");
            template.AppendLine(@"        line-height: 1;           ");
            template.AppendLine(@"        color: #fff;              ");
            template.AppendLine(@"        text-align: center;       ");
            template.AppendLine(@"        white-space: nowrap;      ");
            template.AppendLine(@"    }                             ");
            template.AppendLine(@"    dl {                          ");
            template.AppendLine(@"        margin-top: 0;            ");
            template.AppendLine(@"        margin-bottom: 20px;      ");
            template.AppendLine(@"    }                             ");
            template.AppendLine(@"    dt {                          ");
            template.AppendLine(@"      font-weight: bold;          ");
            template.AppendLine(@"    }                             ");
            template.AppendLine(@"    dt, dd {                      ");
            template.AppendLine(@"        line-height: 1.42857143;  ");
            template.AppendLine(@"    }                             ");
            template.AppendLine(@"    p {                             ");
            template.AppendLine(@"        margin: 0 0 10px;           ");
            template.AppendLine(@"    }                               ");


            template.AppendLine(@"</style>");
            template.AppendLine(@"<body>");

            template.AppendLine("Hello @Model.Name,");
            template.AppendLine(@"<br/>");
            template.AppendLine(@"<br/>");
            template.AppendLine(@"@Model.Applicant applied for a <a href='@Model.JobLink' target='_blank'>job</a> you advertised recently.");

            if (!string.IsNullOrEmpty(entity.ApplicantMessage))
            {
                template.AppendLine(@" Below is the candidate's resume:");
            }
            template.AppendLine(@"<br/>");
            template.AppendLine(@"<br/>");
            template.Append(@entity.ApplicantMessage);

            template.AppendLine(@"</body>");
            template.AppendLine(@"</html>");

            string htmlBody = template.ToString();


            var result = PreMailer.Net.PreMailer.MoveCssInline(htmlBody);

            htmlBody = result.Html;

            // result.Html

            string fromEmail = ParseEmail(entity.ApplicantEmail);

            if (!string.IsNullOrEmpty(fromEmail))
            {
                var message = new MailMessage()
                {
                    IsBodyHtml = true
                };
                Attachment attachment  = getAttachment(entity.CV, cvFolder);
                var        attachments = new List <Attachment>();
                if (attachment != null)
                {
                    attachments.Add(attachment);
                }

                //TODO make sure there is a valid destination email
                string destEmail = entity.JobPost.JobEmail ?? "*****@*****.**";
                var    email     = new Email(fromEmail)
                                   .To(destEmail)
                                   .Subject(subject + entity.ApplicantEmail + "applied for " + entity.JobPost.JobTitle)
                                   .UsingTemplate(htmlBody, new
                {
                    Name      = entity.JobPost.ContactName,
                    Applicant = entity.ApplicantEmail,     // TODO Actually it includes the name as well
                    JobLink   = "http://angjobs.com/#!/jobdetails/" + entity.JobPost.Id
                }, true)
                                   .BodyAsHtml()
                                   .ReplyTo(fromEmail)
                                   .Attach(attachments);

                object fileAttachment = attachment;

                EnsureEmailFolderExists();
                email.SendAsync(SendCompletedEventHandler_NotifyRecruiter, fileAttachment);
            }
        }
Пример #5
0
 public static void NotifyAdmin(Models.JobApplication entity)
 {
     //TODO
     //throw new NotImplementedException();
 }