|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
namespace StateJobsNYSubmit.Pages
|
|
|
|
{
|
|
|
|
public class SettingsModel : PageModel
|
|
|
|
{
|
|
|
|
private readonly ILogger<PrivacyModel> _logger;
|
|
|
|
|
|
|
|
private PrivateData p = new PrivateData();
|
|
|
|
public UserData userData { get; set; }
|
|
|
|
public string skills { get; set; }
|
|
|
|
public SettingsModel(ILogger<PrivacyModel> 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.coverLetter = Request.Cookies["CoverLetter"];
|
|
|
|
skills = Request.Cookies["Skills"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void OnGet()
|
|
|
|
{
|
|
|
|
GetUserData();
|
|
|
|
}
|
|
|
|
public void OnPost()
|
|
|
|
{
|
|
|
|
GetUserData();
|
|
|
|
userData.name = Request.Form["userData.name"];
|
|
|
|
userData.email = Request.Form["userData.email"];
|
|
|
|
userData.smtpHost = Request.Form["userData.smtpHost"];
|
|
|
|
Response.Cookies.Append("Skills", Request.Form["skills"]);
|
|
|
|
Response.Cookies.Append("CoverLetter", Request.Form["userData.coverLetter"]);
|
|
|
|
userData.coverLetter = "";
|
|
|
|
Response.Cookies.Append("PrivateData", p.EncryptString(JsonConvert.SerializeObject(userData)));
|
|
|
|
userData.coverLetter = Request.Cookies["CoverLetter"];
|
|
|
|
skills = Request.Cookies["Skills"];
|
|
|
|
Response.Redirect("/");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|