protected void Apply(NoteEdited e) { var note = _notes.Single(x => x.NoteId == e.NoteId); note.Content = e.Content; note.LastEditTimestamp = e.Timestamp; }
public async Task <bool> StoreNote(NoteItem note) { if (note == null) { throw new ArgumentNullException(nameof(note)); } await Task.Delay(500); NoteItem storedNote; if (!string.IsNullOrEmpty(note.Id)) { storedNote = _notes.FirstOrDefault(n => n.Id == note.Id); if (storedNote == null) { return(false); } storedNote.Title = note.Title; storedNote.Content = note.Content; storedNote.LastEdited = DateTime.Now; NoteEdited?.Invoke(this, new NoteEvent(storedNote.Clone())); } else { storedNote = note; storedNote.Id = (_notes.Last().Id + 1); // todo: replace with Snowflake ID... _notes.Add(storedNote); NoteAdded?.Invoke(this, new NoteEvent(storedNote.Clone())); } return(true); }
public void When(NoteEdited e) { var note = (NoteItem) _items[e.NoteId]; note.Edit(e.NewText); }