public void RemoveNote_CustomDayWithNotes_RemovesNote() { var length = _customDayWithNotes.Notes.Count; _customDayWithNotes.RemoveNote(_dummyDBContext.Note3); Assert.Equal(length - 1, _customDayWithNotes.Notes.Count); }
public ActionResult <Note> RemoveNote(DateTime date, int noteId) { CustomDay dayToEdit = _customDayRepository.GetByDate(date); if (dayToEdit == null) { return(NotFound()); } else { Note noteToRemove = _noteRepository.GetCustomDayNote(date, noteId); if (noteToRemove == null) { return(NotFound()); } else { try { dayToEdit.RemoveNote(noteToRemove); _customDayRepository.SaveChanges(); return(Ok(noteToRemove)); } catch (Exception ex) { return(BadRequest(ex.Message)); } } } }