Generate Cover Letter text using UserData and posting
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
ViewData["Title"] = "Vacancy Submitter";
|
||||
}
|
||||
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="card">
|
||||
@ -11,7 +12,6 @@
|
||||
<h6>Start Here</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
<label for="posting_id">Vacancy ID: </label>
|
||||
<input asp-for="Posting_ID" type="text" id="posting_id" class="form-control" />
|
||||
@ -32,7 +32,6 @@
|
||||
</div>
|
||||
<br />
|
||||
<button type="submit" class="btn btn-primary">Generate Application</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -43,8 +42,7 @@
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>Cover Letter</p>
|
||||
<textarea style="width: 100%"
|
||||
name="cover_letter">Nothing yet, this is where the Cover Letter would go!</textarea>
|
||||
<textarea asp-for="CoverLetter" class="form-control" style="width: 100%; height: 18rem" name="CoverLetter" id="CoverLetter"></textarea>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<button type="submit" class="btn btn-secondary">Submit</button> <button type="submit"
|
||||
@ -55,20 +53,30 @@
|
||||
</div>
|
||||
@if (Model.posting != null)
|
||||
{
|
||||
@if (Model.posting.DateDue < new DateTime()) {
|
||||
<script>
|
||||
alert("Deadline for posting has already passed!");
|
||||
</script>
|
||||
}
|
||||
<div class="col-md-3">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h6>Posting Info</h6>
|
||||
<h6>Posting Info for Vacancy ID @Model.posting.VacancyID, Box @Model.posting.BoxNumber</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>Title: @Model.posting.Title</p>
|
||||
<p>Grade @Model.posting.SalaryGrade</p>
|
||||
<p>Grade: @Model.posting.SalaryGrade</p>
|
||||
<p>Agency: @Model.posting.Agency</p>
|
||||
<p>Union: @Model.posting.BargainingUnit</p>
|
||||
<p>Contact Name: @Model.posting.ContactName</p>
|
||||
<p>Contact Email: <a href="mailto:@Model.posting.ContactEmailAddress?subject=Box # @Model.posting.BoxNumber Vacancy ID @Model.posting.VacancyID">@Model.posting.ContactEmailAddress</a> </p>
|
||||
<p>Contact Email: <a href="mailto:@Model.posting.ContactEmailAddress?subject=Box @Model.posting.BoxNumber, Vacancy @Model.posting.VacancyID">@Model.posting.ContactEmailAddress</a> </p>
|
||||
</div>
|
||||
<div class="card-footer text-muted">
|
||||
Posted @Model.posting.DatePosted.ToString("d"), Applications Due @Model.posting.DateDue.ToString("d")
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
</form>
|
||||
</div>
|
||||
@ -12,6 +12,7 @@ namespace StateJobsNYSubmit.Pages
|
||||
private PrivateData p = new PrivateData();
|
||||
public UserData userData;
|
||||
public string Posting_ID {get; set;}
|
||||
public string CoverLetter {get; set;}
|
||||
public Posting posting = null;
|
||||
public IndexModel(ILogger<IndexModel> logger)
|
||||
{
|
||||
@ -30,9 +31,8 @@ namespace StateJobsNYSubmit.Pages
|
||||
string test = p.DecryptString(cookieValue);
|
||||
userData = JsonConvert.DeserializeObject<UserData>(test);
|
||||
userData.visitCounter++;
|
||||
this.CoverLetter = userData.coverLetter;
|
||||
}
|
||||
Response.Cookies.Append("PrivateData", p.EncryptString(JsonConvert.SerializeObject(userData)));
|
||||
Console.WriteLine($"Value of counter: {userData.visitCounter}");
|
||||
}
|
||||
public void OnGet(string vacancyID)
|
||||
{
|
||||
@ -40,22 +40,26 @@ namespace StateJobsNYSubmit.Pages
|
||||
if (vacancyID != null && !vacancyID.Trim().Equals("")) {
|
||||
posting = new Posting(vacancyID);
|
||||
this.Posting_ID = vacancyID;
|
||||
} else {
|
||||
Console.WriteLine($"Unable to get Posting ID from Get Request URL.");
|
||||
}
|
||||
|
||||
this.CoverLetter = userData.coverLetter;
|
||||
}
|
||||
|
||||
Response.Cookies.Append("PrivateData", p.EncryptString(JsonConvert.SerializeObject(userData)));
|
||||
}
|
||||
public void OnPost()
|
||||
{
|
||||
GetUserData();
|
||||
string vacancyID = Request.Form["posting_id"];
|
||||
string coverLetterFormat = Request.Form["CoverLetter"];
|
||||
userData.coverLetter = coverLetterFormat;
|
||||
if (vacancyID != null && !vacancyID.Trim().Equals("")) {
|
||||
posting = new Posting(vacancyID);
|
||||
this.CoverLetter = posting.GenerateLetter(coverLetterFormat);
|
||||
this.Posting_ID = vacancyID;
|
||||
} else {
|
||||
Console.WriteLine($"Unable to get Posting ID from form.");
|
||||
}
|
||||
|
||||
Response.Cookies.Append("PrivateData", p.EncryptString(JsonConvert.SerializeObject(userData)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
13
Posting.cs
13
Posting.cs
@ -38,7 +38,6 @@ public class Posting
|
||||
public Posting(string id)
|
||||
{
|
||||
string fullUrl = "https://statejobs.ny.gov/employees/vacancyDetailsPrint.cfm?id=" + id;
|
||||
Console.WriteLine(fullUrl);
|
||||
HtmlWeb web = new HtmlWeb();
|
||||
var htmlDoc = web.Load(fullUrl);
|
||||
// extracting all links
|
||||
@ -84,7 +83,19 @@ public class Posting
|
||||
}
|
||||
i++;
|
||||
}
|
||||
Regex boxRegex = new Regex(@"(Box \d+)");
|
||||
this.BoxNumber = boxRegex.Matches(this.NotesOnApplying)[0].Value.Replace("Box ", "");
|
||||
this.BargainingUnit = this.BargainingUnit.Replace("&", "&");
|
||||
this.VacancyID = id;
|
||||
}
|
||||
|
||||
public string GenerateLetter(string s) {
|
||||
string ret = "" + s;
|
||||
ret = ret.Replace("$name", this.ContactName);
|
||||
ret = ret.Replace("$vacancy", this.VacancyID);
|
||||
ret = ret.Replace("$title", this.Title);
|
||||
ret = ret.Replace("$box", this.BoxNumber);
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,9 +4,11 @@
|
||||
public class UserData
|
||||
{
|
||||
public string email { get; set; }
|
||||
public string name {get; set;}
|
||||
public string smtpHost { get; set; }
|
||||
public List<string> skillOptions { get; set; }
|
||||
public string identifier { get; set; }
|
||||
public int visitCounter { get; set;}
|
||||
public string coverLetter { get; set; }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user