You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.3 KiB
65 lines
2.3 KiB
using System; |
|
using System.Collections.Generic; |
|
using Microsoft.AspNetCore.Mvc.RazorPages; |
|
using Microsoft.Extensions.Logging; |
|
using Newtonsoft.Json; |
|
|
|
namespace StateJobsNYSubmit.Pages |
|
{ |
|
public class IndexModel : PageModel |
|
{ |
|
private readonly ILogger<IndexModel> _logger; |
|
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) |
|
{ |
|
_logger = logger; |
|
} |
|
|
|
|
|
public void GetUserData() |
|
{ |
|
userData = new UserData(); |
|
userData.skillOptions = new List<string>(); |
|
userData.visitCounter = 1; |
|
string cookieValue = Request.Cookies["PrivateData"]; |
|
if (cookieValue != null) |
|
{ |
|
string test = p.DecryptString(cookieValue); |
|
userData = JsonConvert.DeserializeObject<UserData>(test); |
|
userData.visitCounter++; |
|
this.CoverLetter = userData.coverLetter; |
|
} |
|
} |
|
public void OnGet(string vacancyID) |
|
{ |
|
GetUserData(); |
|
if (vacancyID != null && !vacancyID.Trim().Equals("")) { |
|
posting = new Posting(vacancyID); |
|
this.Posting_ID = vacancyID; |
|
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))); |
|
} |
|
} |
|
}
|
|
|