|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
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 IndexModel(ILogger<IndexModel> logger)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnGet()
|
|
|
|
|
{
|
|
|
|
|
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++;
|
|
|
|
|
}
|
|
|
|
|
Response.Cookies.Append("PrivateData", p.EncryptString(JsonConvert.SerializeObject(userData)));
|
|
|
|
|
Console.WriteLine($"Value of counter: {userData.visitCounter}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|