feat: initial working version of service refs NOISSUE
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
@page
|
||||
@model IndexModel
|
||||
@{
|
||||
ViewData["Title"] = "Home page";
|
||||
ViewData["Title"] = "Song of the Day";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
|
@@ -1,8 +0,0 @@
|
||||
@page
|
||||
@model PrivacyModel
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
<p>Use this page to detail your site's privacy policy.</p>
|
@@ -1,19 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace sotd.Pages;
|
||||
|
||||
public class PrivacyModel : PageModel
|
||||
{
|
||||
private readonly ILogger<PrivacyModel> _logger;
|
||||
|
||||
public PrivacyModel(ILogger<PrivacyModel> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" asp-area="" asp-page="/Index">sotd</a>
|
||||
<a class="navbar-brand" asp-area="" asp-page="/Index">Song of the Day</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
@@ -24,7 +24,7 @@
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/SuggestionHelpers">Suggestion Helpers</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2025 - sotd - <a asp-area="" asp-page="/Privacy">Privacy</a>
|
||||
© 2025 - Song of the Day
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
|
32
song_of_the_day/Pages/SuggestionHelpers.cshtml
Normal file
32
song_of_the_day/Pages/SuggestionHelpers.cshtml
Normal file
@@ -0,0 +1,32 @@
|
||||
@page
|
||||
@model SuggestionHelpersModel
|
||||
@{
|
||||
ViewData["Title"] = "Suggestion Helpers";
|
||||
}
|
||||
|
||||
<div class="text-left">
|
||||
<table>
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
@foreach (var helper in @Model.SuggestionHelpers)
|
||||
{
|
||||
var title = helper.Title; var description = helper.Description;
|
||||
<tr>
|
||||
<td>@title</td>
|
||||
<td>@description</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
<hr />
|
||||
<form method="post">
|
||||
<label asp-for="NewSuggestionTitle">Title</label>
|
||||
<input asp-for="NewSuggestionTitle" />
|
||||
<br />
|
||||
<label asp-for="NewSuggestionDescription">Description</label>
|
||||
<input asp-for="NewSuggestionDescription" />
|
||||
<br />
|
||||
<input type="submit" title="Submit" />
|
||||
</form>
|
||||
</div>
|
52
song_of_the_day/Pages/SuggestionHelpers.cshtml.cs
Normal file
52
song_of_the_day/Pages/SuggestionHelpers.cshtml.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace sotd.Pages;
|
||||
|
||||
public class SuggestionHelpersModel : PageModel
|
||||
{
|
||||
private readonly ILogger<SuggestionHelpersModel> _logger;
|
||||
|
||||
public SuggestionHelpersModel(ILogger<SuggestionHelpersModel> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
this.NewSuggestionDescription = "";
|
||||
this.NewSuggestionTitle = "";
|
||||
this.SuggestionHelpers = new List<SuggestionHelper>();
|
||||
}
|
||||
|
||||
[BindProperty]
|
||||
public ICollection<SuggestionHelper> SuggestionHelpers { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public string NewSuggestionTitle { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public string NewSuggestionDescription { get; set; }
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
using (var dci = DataContext.Instance)
|
||||
{
|
||||
this.SuggestionHelpers = dci.SuggestionHelpers.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPost()
|
||||
{
|
||||
using (var dci = DataContext.Instance)
|
||||
{
|
||||
var newHelper = new SuggestionHelper()
|
||||
{
|
||||
Title = this.NewSuggestionTitle,
|
||||
Description = this.NewSuggestionDescription
|
||||
};
|
||||
dci.SuggestionHelpers.Add(newHelper);
|
||||
dci.SaveChanges();
|
||||
this.SuggestionHelpers = dci.SuggestionHelpers.ToList();
|
||||
}
|
||||
this.NewSuggestionDescription = "";
|
||||
this.NewSuggestionTitle = "";
|
||||
}
|
||||
}
|
17
song_of_the_day/Pages/User.cshtml
Normal file
17
song_of_the_day/Pages/User.cshtml
Normal file
@@ -0,0 +1,17 @@
|
||||
@page "{userIndex}"
|
||||
@model UserModel
|
||||
@{
|
||||
ViewData["Title"] = "User #" + @Model.userId;
|
||||
}
|
||||
|
||||
<div class="text-left">
|
||||
<form method="post">
|
||||
<label asp-for="UserNickName">Preferred Name</label>
|
||||
<input asp-for="UserNickName" />
|
||||
<br />
|
||||
<label asp-for="UserName">Contact Name</label>
|
||||
<input asp-for="UserName" disabled />
|
||||
<br />
|
||||
<input type="submit" title="Submit" />
|
||||
</form>
|
||||
</div>
|
45
song_of_the_day/Pages/User.cshtml.cs
Normal file
45
song_of_the_day/Pages/User.cshtml.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace sotd.Pages;
|
||||
|
||||
public class UserModel : PageModel
|
||||
{
|
||||
private readonly ILogger<UserModel> _logger;
|
||||
|
||||
public UserModel(ILogger<UserModel> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
this.UserNickName = "";
|
||||
this.UserName = "";
|
||||
}
|
||||
|
||||
public int userId { get; set; }
|
||||
|
||||
public string UserName { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public string UserNickName { get; set; }
|
||||
|
||||
public void OnGet(int userIndex)
|
||||
{
|
||||
using (var dci = DataContext.Instance)
|
||||
{
|
||||
var user = dci.Users.Find(userIndex);
|
||||
this.UserName = user.Name;
|
||||
this.UserNickName = user.NickName;
|
||||
this.userId = userIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPost(int userIndex)
|
||||
{
|
||||
using (var dci = DataContext.Instance)
|
||||
{
|
||||
var user = dci.Users.Find(userIndex);
|
||||
user.NickName = this.UserNickName;
|
||||
dci.SaveChanges();
|
||||
this.UserName = user.Name;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user