Beispiel #1
0
        public Task <NoteEntry> GetByIdAsync(string id)
        {
            NoteEntry entry = null;

            entries.TryGetValue(id, out entry);
            return(Task.FromResult(entry));
        }
Beispiel #2
0
        public static void LoadMockData(this INoteEntryStore store)
        {
            var a = new NoteEntry
            {
                Title = "Sprint Planning Meeting",
                Text  = "1. Scope 2. Backlog 3. Duration"
            };

            var b = new NoteEntry
            {
                Title = "Daily Scrum Stand-up",
                Text  = "1. Yesterday 2. Today 3. Impediments"
            };

            var c = new NoteEntry
            {
                Title = "Sprint Retrospective",
                Text  = "1. Reflection 2. Actions"
            };

            Task.WhenAll(
                store.AddAsync(a),
                store.AddAsync(b),
                store.AddAsync(c))
            .ConfigureAwait(false);
        }
Beispiel #3
0
        public async Task DeleteAsync(NoteEntry entry)
        {
            await InitializeAsync();

            if (loadedNotes.Remove(entry))
            {
                await SaveDataAsync(filename, loadedNotes);
            }
        }
Beispiel #4
0
        public async Task AddAsync(NoteEntry entry)
        {
            await InitializeAsync();

            if (!loadedNotes.Any(ne => ne.Id == entry.Id))
            {
                loadedNotes.Add(entry);
                await SaveDataAsync(filename, loadedNotes);
            }
        }
Beispiel #5
0
        public async Task UpdateAsync(NoteEntry entry)
        {
            await InitializeAsync();

            if (!loadedNotes.Contains(entry))
            {
                throw new Exception($"NoteEntry {entry.Title} was not found in the {nameof(FileEntryStore)}. Did you forget to add it?");
            }

            await SaveDataAsync(filename, loadedNotes);
        }
Beispiel #6
0
 public Task DeleteAsync(NoteEntry entry)
 {
     entries.Remove(entry.Id);
     return(Task.CompletedTask);
 }
Beispiel #7
0
 public Task UpdateAsync(NoteEntry entry)
 {
     return(Task.CompletedTask);
 }
Beispiel #8
0
 public Task AddAsync(NoteEntry entry)
 {
     entries.Add(entry.Id, entry);
     return(Task.CompletedTask);
 }
Beispiel #9
0
 Task INoteEntryStore.DeleteAsync(NoteEntry entry)
 {
     throw new NotImplementedException();
 }
Beispiel #10
0
 public Task UpdateAsync(NoteEntry entry)
 {
     entries.Remove(entry.Id);
     entries.Add(entry.Id, entry);
     return(Task.CompletedTask);
 }