private void SaveOrUpdate() { try { if (Globals.CurrentlyOpenedFile != null) { service.Update(new UpdateFileCommand { Id = Globals.CurrentlyOpenedFile.Id, Author = Globals.CurrentlyOpenedFile.Author, Content = fileContent.Text, Name = Globals.CurrentlyOpenedFile.Name }); signalr.UnlockFile(JsonConvert.SerializeObject(Globals.CurrentlyOpenedFile)); } else { service.Add(new CreateFileCommand { Author = Globals.Credentials.Email, Content = fileContent.Text, Name = this.Title }); var allNotes = service.Get(); Globals.CurrentlyOpenedFile = allNotes.Last(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void should_delete_last_note() { var allNotes = service.Get(); var lastNote = allNotes.Last(); service.Delete(lastNote.Id); var allNotesAfterDeletion = service.Get(); Assert.IsTrue(!allNotesAfterDeletion.Any(x => x.Id == lastNote.Id)); }
public OpenFileDialog(IEasyNoteService service) { this.service = service; InitializeComponent(); try { allNotes = service.Get(); allFiles.ItemsSource = allNotes; } catch (Exception ex) { MessageBox.Show(ex.Message); } }