Merge branch 'dev/multiple-notes'

This commit is contained in:
Ryan Peters
2024-01-06 21:10:06 -05:00
16 changed files with 161 additions and 60 deletions

View File

@ -3,12 +3,14 @@ using BinaryDad.Notes.Services;
namespace BinaryDad.Notes.Controllers
{
[ApiController]
public class ApiController : ControllerBase
{
private readonly INoteService noteService;
public ApiController(INoteService noteService) => this.noteService = noteService;
public string Note() => noteService.Get();
[Route("note/{noteName}")]
public string Note(string noteName) => noteService.GetText(noteName);
}
}

View File

@ -1,4 +1,5 @@
using BinaryDad.Notes.Services;
using BinaryDad.Notes.Models;
using BinaryDad.Notes.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@ -11,10 +12,24 @@ public class NoteController : Controller
public NoteController(INoteService noteService) => this.noteService = noteService;
public IActionResult Index()
[Route("{noteName=default}")]
public IActionResult Index(string noteName)
{
var content = noteService.Get();
var model = new ContentModel
{
CurrentNote = noteName,
Text = noteService.GetText(noteName),
NoteNames = noteService.GetNoteNames()
};
return View((object)content);
return View(model);
}
[Route("{noteName}/delete")]
public IActionResult Delete(string noteName)
{
noteService.DeleteNote(noteName);
return Redirect("/");
}
}