Add project files.
This commit is contained in:
31
Controllers/ApiController.cs
Normal file
31
Controllers/ApiController.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BinaryDad.Notes.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class ApiController : ControllerBase
|
||||
{
|
||||
private readonly string filePath;
|
||||
|
||||
public ApiController(IConfiguration configuration)
|
||||
{
|
||||
filePath = configuration["ContentFilePath"];
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("save")]
|
||||
public async Task<bool> Save()
|
||||
{
|
||||
var content = string.Empty;
|
||||
|
||||
using (var reader = new StreamReader(Request.Body))
|
||||
{
|
||||
content = await reader.ReadToEndAsync();
|
||||
}
|
||||
|
||||
await System.IO.File.WriteAllTextAsync(filePath, content);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
20
Controllers/HomeController.cs
Normal file
20
Controllers/HomeController.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BinaryDad.Notes.Controllers;
|
||||
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly string filePath;
|
||||
|
||||
public HomeController(IConfiguration configuration)
|
||||
{
|
||||
filePath = configuration["ContentFilePath"];
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
var content = System.IO.File.ReadAllText(filePath);
|
||||
|
||||
return View((object)content);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user