convert to use service
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using BinaryDad.Notes.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BinaryDad.Notes.Controllers;
|
||||
|
||||
@ -6,11 +7,11 @@ namespace BinaryDad.Notes.Controllers;
|
||||
[Route("[controller]")]
|
||||
public class ApiController : ControllerBase
|
||||
{
|
||||
private readonly string filePath;
|
||||
private readonly INoteService noteService;
|
||||
|
||||
public ApiController(IConfiguration configuration)
|
||||
public ApiController(INoteService noteService)
|
||||
{
|
||||
filePath = configuration["ContentFilePath"];
|
||||
this.noteService = noteService;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@ -24,7 +25,7 @@ public class ApiController : ControllerBase
|
||||
content = await reader.ReadToEndAsync();
|
||||
}
|
||||
|
||||
await System.IO.File.WriteAllTextAsync(filePath, content);
|
||||
noteService.Save(content);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,19 +1,20 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using BinaryDad.Notes.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BinaryDad.Notes.Controllers;
|
||||
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly string filePath;
|
||||
private readonly INoteService noteService;
|
||||
|
||||
public HomeController(IConfiguration configuration)
|
||||
public HomeController(INoteService noteService)
|
||||
{
|
||||
filePath = configuration["ContentFilePath"];
|
||||
this.noteService = noteService;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
var content = System.IO.File.ReadAllText(filePath);
|
||||
var content = noteService.Get();
|
||||
|
||||
return View((object)content);
|
||||
}
|
||||
|
Reference in New Issue
Block a user