Browse Source

Add settings controls

master
Gregory Rudolph 4 years ago
parent
commit
9ad421173c
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 5
      Pages/Index.cshtml
  2. 35
      Pages/Settings.cshtml
  3. 14
      Pages/Settings.cshtml.cs

5
Pages/Index.cshtml

@ -35,6 +35,8 @@
</div> </div>
</div> </div>
</div> </div>
@if (Model.posting != null)
{
<div class="col-md-6"> <div class="col-md-6">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
@ -51,8 +53,7 @@
</div> </div>
</div> </div>
@if (Model.posting != null)
{
@if (Model.posting.DateDue < new DateTime()) { @if (Model.posting.DateDue < new DateTime()) {
<script> <script>
alert("Deadline for posting has already passed!"); alert("Deadline for posting has already passed!");

35
Pages/Settings.cshtml

@ -2,4 +2,37 @@
@model SettingsModel @model SettingsModel
@{ @{
ViewData["Title"] = "Settings"; ViewData["Title"] = "Settings";
} }
<div class="container">
<div class="card">
<div class="card-header">
Settings
</div>
<div class="card-body">
<form method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="userData.email">Email: </label>
<input asp-for="userData.email" />
</div>
<div class="form-group">
<label for="userData.name">Name: </label>
<input asp-for="userData.name" />
</div>
<div class="form-group">
<label for="userData.smtpHost">Email Host:</label>
<input asp-for="userData.smtpHost" />
</div>
<div class="form-group">
<label for="userData.coverLetter">Cover Letter Format:</label>
<textarea asp-for="userData.coverLetter" style="width: 100%; height: 18rem"></textarea>
</div>
<button type="submit" class="btn btn-primary">Save Settings</button>
</form>
</div>
<div class="card-footer">
Visits: @Model.userData.visitCounter
</div>
</div>
</div>

14
Pages/Settings.cshtml.cs

@ -11,7 +11,8 @@ namespace StateJobsNYSubmit.Pages
private readonly ILogger<PrivacyModel> _logger; private readonly ILogger<PrivacyModel> _logger;
private PrivateData p = new PrivateData(); private PrivateData p = new PrivateData();
public UserData userData; public UserData userData { get; set; }
public string skills { get; set; }
public SettingsModel(ILogger<PrivacyModel> logger) public SettingsModel(ILogger<PrivacyModel> logger)
{ {
_logger = logger; _logger = logger;
@ -26,13 +27,20 @@ namespace StateJobsNYSubmit.Pages
{ {
string test = p.DecryptString(cookieValue); string test = p.DecryptString(cookieValue);
userData = JsonConvert.DeserializeObject<UserData>(test); userData = JsonConvert.DeserializeObject<UserData>(test);
userData.visitCounter++;
} }
Response.Cookies.Append("PrivateData", p.EncryptString(JsonConvert.SerializeObject(userData))); Response.Cookies.Append("PrivateData", p.EncryptString(JsonConvert.SerializeObject(userData)));
Console.WriteLine($"Value of counter: {userData.visitCounter}");
} }
public void OnGet() 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("PrivateData", p.EncryptString(JsonConvert.SerializeObject(userData)));
} }
} }
} }

Loading…
Cancel
Save