Ejemplo n.º 1
0
        public void AddCorrectNote(string note)
        {
            var newNote = new Notes {
                Note = note
            };
            var expectedJson = new List <Notes>
            {
                new Notes {
                    Note = "456"
                },
                new Notes {
                    Note = "123"
                },
                new Notes {
                    Note = "789"
                },
                new Notes {
                    Note = "9999"
                },
                new Notes {
                    Note = note
                }
            };

            _notes.AddNote(newNote);
            var resultJson = _notes.GetNotes();

            Assert.IsTrue(CompareListsOfNotes(expectedJson, resultJson));
        }
Ejemplo n.º 2
0
        public IActionResult AddNote([FromBody] string note)
        {
            if (!string.IsNullOrEmpty(note))
            {
                var newNote = new Notes {
                    Note = note
                };

                _myNotesRepository.AddNote(newNote);
                _myNotesRepository.SaveAsJson();

                ViewBag.response = "Note \"" + note + "\" added.";
            }
            else
            {
                ViewBag.response = "Note isn't added.";
            }

            return(View("AddResult"));
        }