Merge branch 'master' into dev/multiple-notes
This commit is contained in:
37
Controllers/NoteController.cs
Normal file
37
Controllers/NoteController.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using BinaryDad.Notes.Models;
|
||||
using BinaryDad.Notes.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BinaryDad.Notes.Controllers;
|
||||
|
||||
[Authorize]
|
||||
public class NoteController : Controller
|
||||
{
|
||||
private readonly INoteService noteService;
|
||||
|
||||
public NoteController(INoteService noteService)
|
||||
{
|
||||
this.noteService = noteService;
|
||||
}
|
||||
|
||||
[Route("{noteName?}")]
|
||||
public IActionResult Index(string? noteName)
|
||||
{
|
||||
var model = new ContentModel
|
||||
{
|
||||
Text = noteService.GetText(noteName),
|
||||
NoteNames = noteService.GetNoteNames()
|
||||
};
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[Route("{noteName}/delete")]
|
||||
public IActionResult Delete(string noteName)
|
||||
{
|
||||
noteService.DeleteNote(noteName);
|
||||
|
||||
return Redirect("/");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user