NoteMAUI/App.xaml.cs

37 lines
1.1 KiB
C#

using NotesDataAnalyst.NoteContent;
namespace NotesDataAnalyst
{
public partial class App : Application
{
public static List<Note> AllNotes { get; set; } = new List<Note>();
public static DatabaseContext Database { get; private set; }
public App()
{
InitializeComponent();
string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "notes.db");
Database = new DatabaseContext(dbPath);
MainPage = new AppShell();
}
// Метод для добавления или сохранения заметки
public static void SaveNote(Note note)
{
var existingNote = AllNotes.FirstOrDefault(n => n.Id == note.Id);
if (existingNote == null)
{
AllNotes.Add(note);
}
else
{
// Обновляем существующую заметку
existingNote.Title = note.Title;
existingNote.Text = note.Text;
}
}
}
}