working nicely
This commit is contained in:
@ -2,18 +2,14 @@
|
||||
{
|
||||
public class FileNoteService : INoteService
|
||||
{
|
||||
private readonly string defaultFileName;
|
||||
private readonly string filePath;
|
||||
|
||||
public FileNoteService(IConfiguration configuration)
|
||||
{
|
||||
defaultFileName = configuration["DefaultContentFileName"].Trim().ToLower();
|
||||
filePath = configuration["ContentFilePath"].Trim();
|
||||
|
||||
CheckFile(defaultFileName);
|
||||
filePath = configuration["FileNoteService:ContentFilePath"].Trim();
|
||||
}
|
||||
|
||||
public string GetText(string? noteName)
|
||||
public string GetText(string noteName)
|
||||
{
|
||||
CheckFile(noteName);
|
||||
|
||||
@ -27,7 +23,7 @@
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public void SaveText(string content, string? noteName)
|
||||
public void SaveText(string content, string noteName)
|
||||
{
|
||||
File.WriteAllText(GetFilePath(noteName), content);
|
||||
}
|
||||
@ -39,7 +35,7 @@
|
||||
File.Delete(filePath);
|
||||
}
|
||||
|
||||
private void CheckFile(string? noteName)
|
||||
private void CheckFile(string noteName)
|
||||
{
|
||||
var filePath = GetFilePath(noteName);
|
||||
|
||||
@ -50,10 +46,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
private string GetFilePath(string? noteName)
|
||||
private string GetFilePath(string noteName)
|
||||
{
|
||||
noteName = string.IsNullOrWhiteSpace(noteName) ? defaultFileName : noteName;
|
||||
|
||||
noteName = noteName.Trim().ToLower();
|
||||
|
||||
return Path.Combine(filePath, noteName);
|
||||
|
@ -3,8 +3,8 @@
|
||||
public interface INoteService
|
||||
{
|
||||
ICollection<string> GetNoteNames();
|
||||
string GetText(string? noteName);
|
||||
void SaveText(string content, string? noteName);
|
||||
string GetText(string noteName);
|
||||
void SaveText(string content, string noteName);
|
||||
void DeleteNote(string noteName);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user