Add project files.

This commit is contained in:
Ryan Peters
2022-11-29 10:14:15 -05:00
parent dbc1518c89
commit 36f469b9fd
33 changed files with 14596 additions and 0 deletions

View 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;
}
}

View 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);
}
}