Merge branch 'dev/multiple-notes'
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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("/");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user