private void List() { List <Note> notes = _noteRepository.GetAll(); foreach (Note note in notes) { Console.WriteLine(note); } }
private void ListNotes() { List <Note> notes = _noteRepository.GetAll(); foreach (Note note in notes) { Console.WriteLine($"{note.Title} - {note.Content} - {note.CreateDateTime}"); } Console.WriteLine(""); }
private void List() { List <Note> notes = _noteRepository.GetAll(); foreach (Note note in notes) { Console.WriteLine($"Title: {note.Title}\nContent: {note.Content}"); Console.WriteLine("-----------------------"); } }
private void List() { List <Note> noteEntries = _noteRepository.GetAll(); foreach (Note note in noteEntries) { Console.WriteLine($@"Title: {note.Title} Content: {note.Content} Date: {note.CreateDateTime} Post: {note.Post.Title}"); } }
public void UpdateNoteTags_AddingAllTheExistingTagsToAnExistingNoteThatHasNoTags() { using (var context = new NexusContext(_options)) { var note = DataProvider.CreateNote(); var tags = DataProvider.GetAlphabeticalTags(); context.Notes.Add(note); context.Tags.AddRange(tags); context.SaveChanges(); } using (var context = new NexusContext(_options)) { var noteRepo = new NoteRepository(context); var note = noteRepo.GetAll().Single(); noteRepo.UpdateNoteTags(note.Id, DataProvider.GetAlphabeticalTags().Select(t => t.Title)); noteRepo.UnitOfWork.SaveChanges(); } using (var context = new NexusContext(_options)) { var note = context.Notes.Include(n => n.NoteTags).ThenInclude(nt => nt.Tag).First(); Assert.Equal(3, note.NoteTags.Count); Assert.Contains(note.NoteTags, nt => nt.Tag.Title == "A"); Assert.Contains(note.NoteTags, nt => nt.Tag.Title == "B"); Assert.Contains(note.NoteTags, nt => nt.Tag.Title == "C"); } }
public void UpdateNoteTags_RemovingExistingNoteTags() { // SEEDING using (var context = new NexusContext(_options)) { context.Database.EnsureCreated(); // Creates the in-memory SQLite database var note = DataProvider.CreateNote().AssignNoteTags(DataProvider.GetAlphabeticalTags()); context.Notes.Add(note); context.SaveChanges(); } using (var context = new NexusContext(_options)) { var repo = new NoteRepository(context); var note = repo.GetAll().First(); repo.UpdateNoteTags(note.Id, new List <string>()); repo.UnitOfWork.SaveChanges(); } using (var context = new NexusContext(_options)) { var note = context.Notes.Include(n => n.NoteTags).First(); Assert.False(note.NoteTags.Any()); } }
public void UpdateNoteTags_AddingNewTagBeforeAnExistingTag() { using (var context = new NexusContext(_options)) { context.Notes.Add(DataProvider.CreateNote()); context.Tags.AddRange(DataProvider.GetAlphabeticalTags()); context.SaveChanges(); } using (var context = new NexusContext(_options)) { var repo = new NoteRepository(context); var note = repo.GetAll().First(); repo.UpdateNoteTags(note.Id, new List <string>() { "X", "A" }); repo.UnitOfWork.SaveChanges(); } using (var context = new NexusContext(_options)) { var note = context.Notes.Include(n => n.NoteTags).ThenInclude(nt => nt.Tag).First(); Assert.True(note.NoteTags.Count == 2); Assert.Contains(note.NoteTags, nt => nt.Tag.Title == "A"); Assert.Contains(note.NoteTags, nt => nt.Tag.Title == "X"); } }
public void UpdateNoteTags_GivenTheSameNoteTagsToUpdateNotesTags() { using (var context = new NexusContext(_options)) { context.Database.EnsureCreated(); var note = DataProvider.CreateNote(); var tags = DataProvider.GetAlphabeticalTags(); note.AssignNoteTags(tags); context.Notes.Add(note); context.SaveChanges(); } using (var context = new NexusContext(_options)) { var noteRepo = new NoteRepository(context); var note = noteRepo.GetAll().Single(); noteRepo.UpdateNoteTags(note.Id, DataProvider.GetAlphabeticalTags().Select(t => t.Title)); noteRepo.UnitOfWork.SaveChanges(); } using (var context = new NexusContext(_options)) { var note = context.Notes.Include(n => n.NoteTags).ThenInclude(nt => nt.Tag).First(); Assert.Equal(3, note.NoteTags.Count); Assert.Contains(note.NoteTags, nt => nt.Tag.Title == "A"); Assert.Contains(note.NoteTags, nt => nt.Tag.Title == "B"); Assert.Contains(note.NoteTags, nt => nt.Tag.Title == "C"); } }
private Note Choose(string prompt = null) { if (prompt == null) { prompt = "Please choose a note note:"; } Console.WriteLine(prompt); List <Note> notes = _noteRepository.GetAll(); for (int i = 0; i < notes.Count; i++) { Note note = notes[i]; Console.WriteLine($" {i + 1}) {note.Title}"); } Console.Write("> "); string input = Console.ReadLine(); Note chosen = null; try { int choice = int.Parse(input); chosen = notes[choice - 1]; } catch (Exception ex) { Console.WriteLine("Invalid Selection"); } return(chosen); }
public void UpdateNoteTags_NoteHasNoTags_AddingBrandNewTagsToAnExistingNote() { string databaseName = Guid.NewGuid().ToString(); var options = InMemoryHelpers.CreateOptions(databaseName); using (var context = new NexusContext(options)) { var note = DataProvider.CreateNote(); context.Notes.Add(note); context.SaveChanges(); } using (var context = new NexusContext(options)) { var repo = new NoteRepository(context); var tagsToBeAdded = DataProvider.GetAlphabeticalTags(); var note = repo.GetAll().First(); repo.UpdateNoteTags(note.Id, tagsToBeAdded.Select(t => t.Title)); repo.UnitOfWork.SaveChanges(); } using (var context = new NexusContext(options)) { var note = context.Notes.Include(n => n.NoteTags).ThenInclude(nt => nt.Tag).First(); Assert.Equal(3, note.NoteTags.Count); Assert.Contains(note.NoteTags, nt => nt.Tag.Title == "A"); Assert.Contains(note.NoteTags, nt => nt.Tag.Title == "B"); Assert.Contains(note.NoteTags, nt => nt.Tag.Title == "C"); } }
private void AddNewNoteToList() { var recentNote = NoteRepository .GetAll(x => x.UserId == Settings.CurrentUserId) .OrderByDescending(x => x.CreationDate) .FirstOrDefault(); _allNotes.Insert(0, recentNote); Notes.Insert(0, recentNote); }
private void DisplayData() { if (!SearchMode) { grvNotes.DataSource = _repo.GetAll(PageIndex); } else // 검색 결과 리스트 { grvNotes.DataSource = _repo.GetSeachAll(PageIndex, SearchField, SearchQuery); } grvNotes.DataBind(); }
public ActionResult Note(string id) { var item = _noteRepository.GetAll().FirstOrDefault(x => x.PublicId == id); if (item == null) { return(Get404()); } ViewBag.Note = item; return(View("Note", "_NoLayout")); }
private void DisplayData() { if (SearchMode == false) //기본 리스트 { ctlBoardList.DataSource = _repository.GetAll(PageIndex); } else // 검색 결과 리스트 { ctlBoardList.DataSource = _repository.GetsearchAll(PageIndex, SearchField, SearchQuery); } ctlBoardList.DataBind(); }
public NoteSearch SortByDate() { var books = BookRepository.GetAll(); books.Insert(0, null); var noteSearch = new NoteSearch { Notes = NoteRepository.GetAll().Select(SNote.DtoS).ToList(), Books = new SelectList(books, "Id", "Title") }; return(noteSearch); }
private void DisplayData() { if (!SearchMode) // 기본 전체 리스트 { this.ctlBoardList.DataSource = _repository.GetAll(intPage); } else // 검색 결과 리스트 { this.ctlBoardList.DataSource = _repository.GetSearchAll(intPage, SearchField, SearchQuery); } this.ctlBoardList.DataBind(); }
public void UpdateNoteTags_NoteHasTags_AddingNewANDExistingTag() { var options = SQLiteHelpers.CreateOptions(); using (var context = new NexusContext(options)) { context.Database.EnsureCreated(); context.Notes.Add(DataProvider.CreateNote().AssignNoteTags(DataProvider.GetAlphabeticalTags())); context.Tags.Add(new Tag() { Title = "D" }); context.SaveChanges(); } using (var context = new NexusContext(options)) { var repo = new NoteRepository(context); var note = repo.GetAll().First(); repo.UpdateNoteTags(note.Id, new List <string>() { "A", "B", "X", "D" }); repo.UnitOfWork.SaveChanges(); } using (var context = new NexusContext(options)) { var note = context.Notes.Include(n => n.NoteTags).ThenInclude(nt => nt.Tag).First(); Assert.True(note.NoteTags.Count == 4); Assert.Contains(note.NoteTags, nt => nt.Tag.Title == "A"); Assert.Contains(note.NoteTags, nt => nt.Tag.Title == "B"); Assert.Contains(note.NoteTags, nt => nt.Tag.Title == "X"); Assert.Contains(note.NoteTags, nt => nt.Tag.Title == "D"); int totalTagCount = context.Tags.Count(); Assert.True(totalTagCount == 5); } }
public ActionResult ListNotes(int parentId) { if (AuthenticationService.LoggedUser == null) { return(RedirectToAction("Login", "Default")); } else { if (parentId > 0) { Contact contact = new Contact(); contact = ContactRepository.GetByID(parentId); model.ContactName = contact.FullName; model.ParentContactId = parentId; model.NoteList = NoteRepository.GetAll(filter: c => c.ContactId == parentId); } } return(View(model)); }
private void LoadNotesFromDatabase() { _currentSkipCounter = 10; if (bool.TryParse(Settings.UseSafeMode, out bool result)) { if (result) { _allNotes = new List <Note>(); return; } } _allNotes = NoteRepository .GetAll(x => x.UserId == Settings.CurrentUserId) .OrderByDescending(x => x.CreationDate) .ToList(); if (_allNotes.Count > NotesPerLoad) { Notes = _allNotes .Take(NotesPerLoad) .ToObservableCollection(); } else { Notes = _allNotes.ToObservableCollection(); } if (SearchText != null) { Notes = Notes .Where(CheckSearchText) .ToObservableCollection(); } }
private void List() { List <Note> notes = _noteRepository.GetAll(); }
public IHttpActionResult Get() { return(Ok(noteRepo.GetAll())); }
public IActionResult Get() { var dbNotes = _noteRepository.GetAll(); return(Ok(dbNotes)); }
// 최근 글 10개 출력 API // localhost/api/NoteService?page=1 이런식으로 사용하면 해당 데이터가 출력됨 // 데이터 출력 API, JSON 데이터로 전송됨 // GET: api/NoteService public IEnumerable <Note> Get() { return(_repository.GetAll(0).AsEnumerable()); }
public List <Note> GetAllNotes() { return(repository.GetAll()); }
public async Task <ActionResult <IEnumerable <NoteCollection> > > Get() { var noteCollections = await _noteRepository.GetAll(); return(new ObjectResult(noteCollections)); }
public IEnumerable <Note> Get() { return(noteRepository.GetAll()); }
public IEnumerable <Note> Get() { return(repo.GetAll()); }
public async Task <ActionResult <IEnumerable <NoteItem> > > Get() { return(await noteRepository.GetAll()); }