Only let user into posting if they are set up properly.

This commit is contained in:
2021-08-03 08:33:38 -04:00
parent 74cf7e2c91
commit b55884129e
4 changed files with 27 additions and 15 deletions

View File

@ -43,6 +43,9 @@ namespace StateJobsNYSubmit.Pages
public void OnGet(string vacancyID)
{
GetUserData();
if (userData.skillOptions.Count == 0) {
Response.Redirect("Settings");
}
if (vacancyID != null && !vacancyID.Trim().Equals(""))
{
posting = new Posting(vacancyID);
@ -57,16 +60,25 @@ namespace StateJobsNYSubmit.Pages
string coverLetterFormat = Request.Cookies["CoverLetter"];
if (vacancyID != null && !vacancyID.Trim().Equals(""))
{
posting = new Posting(vacancyID);
if (!string.IsNullOrEmpty(Request.Form["SkillCheckboxes"]))
try
{
this.CoverLetter = posting.GenerateLetter(coverLetterFormat, userData, Request.Form["SkillCheckboxes"]);
posting = new Posting(vacancyID.Trim());
if (!string.IsNullOrEmpty(Request.Form["SkillCheckboxes"]))
{
this.CoverLetter = posting.GenerateLetter(coverLetterFormat, userData, Request.Form["SkillCheckboxes"]);
}
this.Posting_ID = vacancyID;
}
catch (Exception e)
{
Console.WriteLine($"Vacancy ID {vacancyID} caused exception {e}");
_logger.LogError(e.ToString());
}
this.Posting_ID = vacancyID;
}
else
{
Console.WriteLine($"Unable to get Posting ID from form.");
_logger.LogDebug($"Unable to get Posting ID from form.");
}
}

View File

@ -7,26 +7,26 @@
<div class="container">
<div class="card">
<div class="card-header">
Settings
Settings - Don't forget to save!
</div>
<div class="card-body">
<form method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="userData.name">Name: </label>
<input asp-for="userData.name" />
<label for="userData.email">Email: </label>
<input asp-for="userData.email" />
<input asp-for="userData.name" class="form-control"/>
<label for="userData.email" >Email: </label>
<input asp-for="userData.email" class="form-control" />
<label for="userData.smtpHost">Email Host:</label>
<input asp-for="userData.smtpHost" />
<input asp-for="userData.smtpHost" class="form-control" />
</div>
<div class="form-group">
<label for="userData.coverLetter">Cover Letter Format:</label>
<textarea asp-for="userData.coverLetter" style="width: 100%; height: 18rem"></textarea>
<small class="text-muted">Write your cover letter above, using variables like $name, $title, $vacancy, $box to auto-fill from the posting.</small>
<textarea asp-for="userData.coverLetter" style="width: 100%; height: 18rem" class="form-control" ></textarea>
<small class="text-muted">Write your cover letter above, using variables like $name, $title, $vacancy, $box, and $skills to auto-fill from the posting.</small>
</div>
<div class="form-group">
<label for="skills">Skills:</label>
<textarea asp-for="skills" style="width: 100%; height: 18rem"></textarea>
<textarea asp-for="skills" style="width: 100%; height: 18rem" class="form-control" ></textarea>
<small class="text-muted">List your skills for applications above, one skill per line.</small>
</div>
<button type="submit" class="btn btn-primary">Save Settings</button>

View File

@ -47,6 +47,7 @@ namespace StateJobsNYSubmit.Pages
Response.Cookies.Append("PrivateData", p.EncryptString(JsonConvert.SerializeObject(userData)));
userData.coverLetter = Request.Cookies["CoverLetter"];
skills = Request.Cookies["Skills"];
Response.Redirect("/");
}
}
}