Example #1
0
        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("");
        }
Example #3
0
        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");
            }
        }
Example #9
0
        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);
        }
Example #10
0
        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");
            }
        }
Example #11
0
        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);
        }
Example #12
0
 private void DisplayData()
 {
     if (!SearchMode)
     {
         grvNotes.DataSource = _repo.GetAll(PageIndex);
     }
     else // 검색 결과 리스트
     {
         grvNotes.DataSource = _repo.GetSeachAll(PageIndex, SearchField, SearchQuery);
     }
     grvNotes.DataBind();
 }
Example #13
0
        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"));
        }
Example #14
0
 private void DisplayData()
 {
     if (SearchMode == false) //기본 리스트
     {
         ctlBoardList.DataSource = _repository.GetAll(PageIndex);
     }
     else // 검색 결과 리스트
     {
         ctlBoardList.DataSource = _repository.GetsearchAll(PageIndex, SearchField, SearchQuery);
     }
     ctlBoardList.DataBind();
 }
Example #15
0
        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);
        }
Example #16
0
        private void DisplayData()
        {
            if (!SearchMode) // 기본 전체 리스트
            {
                this.ctlBoardList.DataSource = _repository.GetAll(intPage);
            }
            else // 검색 결과 리스트
            {
                this.ctlBoardList.DataSource = _repository.GetSearchAll(intPage, SearchField, SearchQuery);
            }

            this.ctlBoardList.DataBind();
        }
Example #17
0
        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);
            }
        }
Example #18
0
 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));
 }
Example #19
0
        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();
 }
Example #21
0
 public IHttpActionResult Get()
 {
     return(Ok(noteRepo.GetAll()));
 }
Example #22
0
        public IActionResult Get()
        {
            var dbNotes = _noteRepository.GetAll();

            return(Ok(dbNotes));
        }
Example #23
0
 // 최근 글 10개 출력 API
 // localhost/api/NoteService?page=1 이런식으로 사용하면 해당 데이터가 출력됨
 // 데이터 출력 API, JSON 데이터로 전송됨
 // GET: api/NoteService
 public IEnumerable <Note> Get()
 {
     return(_repository.GetAll(0).AsEnumerable());
 }
Example #24
0
 public List <Note> GetAllNotes()
 {
     return(repository.GetAll());
 }
Example #25
0
        public async Task <ActionResult <IEnumerable <NoteCollection> > > Get()
        {
            var noteCollections = await _noteRepository.GetAll();

            return(new ObjectResult(noteCollections));
        }
Example #26
0
 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());
 }