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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user