feat: initial working version of service refs NOISSUE
This commit is contained in:
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 = "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user