add delete endpoint
This commit is contained in:
parent
b60a246c34
commit
faaa0dba8f
@ -24,4 +24,12 @@ public class HomeController : Controller
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[Route("{noteName}/delete")]
|
||||
public IActionResult Delete(string noteName)
|
||||
{
|
||||
noteService.DeleteNote(noteName);
|
||||
|
||||
return Redirect("/");
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,13 @@
|
||||
File.WriteAllText(GetFilePath(noteName), content);
|
||||
}
|
||||
|
||||
public void DeleteNote(string noteName)
|
||||
{
|
||||
var filePath = GetFilePath(noteName);
|
||||
|
||||
File.Delete(filePath);
|
||||
}
|
||||
|
||||
private void CheckFile(string noteName)
|
||||
{
|
||||
var filePath = GetFilePath(noteName);
|
||||
|
@ -5,5 +5,6 @@
|
||||
ICollection<string> GetNoteNames();
|
||||
string GetText(string? noteName);
|
||||
void SaveText(string content, string? noteName);
|
||||
void DeleteNote(string noteName);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user