Exemple #1
0
        public void GetAll_Return_TodoItems()
        {
            //Act
            var data = _todoItemService.GetAll();

            //Assert
            Assert.IsAssignableFrom <IQueryable <TodoItem> >(data);
        }
        /// <summary>
        /// 爬取搜尋頁面
        /// </summary>
        /// <returns></returns>
        private bool CrawlSearchPages()
        {
            _todoItemService.DeleteExistedTodoItems();

            // 檢查上次是否有爬到一半的待辦項目
            var todoItems = _todoItemService.GetAll();

            if (!todoItems.Any())
            {
                SearchKeywords();

                // 取得搜尋頁面所有項目
                var itemIds = _searchService.GetAllItemNames();

                // 加入尚未處理的項目到待辦項目佇列中
                _todoItemService.AddTodoItems(itemIds.Select(x => new TodoItem {
                    ItemId = x
                }).ToList());

                // 取得可處理的待辦項目
                todoItems = _todoItemService.GetAll();

                // 搜尋頁面已處理完則結束
                if (!todoItems.Any())
                {
                    return(false);
                }
            }

            foreach (var todoItem in todoItems)
            {
                try
                {
                    // 爬取新的履歷項目
                    var userWithItem = _itemService.GetUserWithItem(todoItem.ItemId);
                    using (var ts = new TransactionScope())
                    {
                        if (userWithItem != null)
                        {
                            _userService.AddUserWithItem(userWithItem);
                        }

                        _todoItemService.Remove(todoItem);

                        ts.Complete();
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError(30001, ex, $"TodoItem {todoItem.ItemId} Exception.");
                }
            }

            return(true);
        }
Exemple #3
0
        async Task ExecuteFetchTodoItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy       = true;
            IsRefreshing = false;

            try
            {
                TodoItems.Clear();
                var todoItems = await todoItemService.GetAll();

                foreach (var item in todoItems)
                {
                    TodoItems.Add(item);
                }
            }
            catch (Exception ex)
            {
                // TODO: show alert
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy       = false;
                IsRefreshing = false;
            }
        }
        public async Task WillGetAllItems()
        {
            // Arrange
            var mockItems = new List <TodoItem>
            {
                new TodoItem
                {
                    Name       = "mock name",
                    IsComplete = false,
                },
            };

            todoItemRepository.GetAll().Returns(mockItems);

            // Act
            var actual = await sut.GetAll();

            // Assert
            Assert.AreEqual(actual.First(), mockItems.First());
        }
Exemple #5
0
        public IActionResult Index()
        {
            var todoList = _todoItemService.GetAll();


            TodoListPageModel viewModel = new TodoListPageModel {
                CompletedTodoItems   = _mapper.Map <List <TodoItemViewModel> >(todoList.Where(t => t.IsComplete).OrderByDescending(t => t.CompleteDate)),
                UnCompletedTodoItems = _mapper.Map <List <TodoItemViewModel> >(todoList.Where(t => !t.IsComplete))
            };

            return(View(viewModel));
        }
Exemple #6
0
        public IActionResult Get()
        {
            var todoList = _mapper.Map <List <TodoItemModel> >(_todoItemService.GetAll());

            return(Ok(todoList));
        }
Exemple #7
0
 public async Task <ActionResult <IEnumerable <TodoItem> > > GetTodoItems()
 {
     return(Ok(await _todoItemService.GetAll()));
 }
 public IActionResult Read()
 {
     return(Ok(_todoItemService.GetAll()));
 }
Exemple #9
0
 public void PopulateData()
 {
     _solr.Delete(SolrQuery.All);
     _solr.AddRange(_todoItemService.GetAll());
     _solr.Commit();
 }
 public ActionResult <IEnumerable <TodoItemRetrieve> > Get()
 {
     return(Ok(_itemService.GetAll()));
 }
        public IEnumerable <TodoItemViewModel> Get()
        {
            Mapper.CreateMap <TodoItemDTO, TodoItemViewModel>();
            var result = Mapper.Map <IEnumerable <TodoItemDTO>, List <TodoItemViewModel> >(itemService.GetAll(1));

            //return Mapper.Map<IEnumerable<TodoItemDTO>, List<TodoItemViewModel>>(itemService.GetAll(1));
            return(result);
        }