예제 #1
0
        public void Delete(Guid id)
        {
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Notes", $"{id}.txt");

            File.Delete(path);

            Note = new Note();
            ParentModel.GetNotes();
        }
예제 #2
0
        public void SaveChanges(Guid id)
        {
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Notes");

            bool   isExist  = id != Guid.Empty;
            string noteName = isExist ? $"{id}.txt" : $"{Guid.NewGuid()}.txt";

            path = $"{path}\\{noteName}";

            File.WriteAllText(path, string.Empty);
            using (var writer = new StreamWriter(path))
            {
                writer.WriteLine(NoteConstants.TITLE + Note.Title);
                writer.WriteLine(NoteConstants.TEXT + Note.Text);
                writer.WriteLine(NoteConstants.COLOR + Note.Color);
                writer.WriteLine(NoteConstants.DATE_CREATED + DateTime.UtcNow);
            }

            Note = new Note();
            ParentModel.GetNotes();
        }