diff --git a/Pages/Index.cshtml.cs b/Pages/Index.cshtml.cs index 3f90ab6..d63d674 100644 --- a/Pages/Index.cshtml.cs +++ b/Pages/Index.cshtml.cs @@ -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 + { + + 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) { - this.CoverLetter = posting.GenerateLetter(coverLetterFormat, userData, Request.Form["SkillCheckboxes"]); + 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."); } } diff --git a/Pages/Settings.cshtml b/Pages/Settings.cshtml index 1d9f1b5..69e27fa 100644 --- a/Pages/Settings.cshtml +++ b/Pages/Settings.cshtml @@ -7,26 +7,26 @@