コード例 #1
0
        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);
            }
        }
コード例 #2
0
ファイル: APITests.cs プロジェクト: mbuchcik/easynotewpf
        public void should_add_note_not_throw_exception()
        {
            var newNote = new CreateFileCommand
            {
                Name = $"Test file {DateTime.Now.Ticks}",
                Author = "ApiTester",
                Content = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
            };

            bool exceptionThrown = false;
            try
            {
                service.Add(newNote);
            }
            catch
            {
                exceptionThrown = true;
            }

            Assert.IsFalse(exceptionThrown);
        }