Exemplo n.º 1
0
        public IActionResult Get()
        {
            var result = _todoItemsService.GetAll();

            if (result?.Any() == false)
            {
                return(NoContent());
            }

            return(Ok(result));
        }
Exemplo n.º 2
0
 public async Task <ActionResult <IEnumerable <TodoItem> > > GetTodoItems()
 {
     try
     {
         return(Ok(await _todoItemsService.GetAll()));
     }
     catch (Exception ex)
     {
         return(StatusCode(599, ex.Message));
     }
 }
        public IActionResult Get()
        {
            var todos = service.GetAll();

            if (!todos.Any())
            {
                return(new NotFoundResult());
            }
            else
            {
                return(new ObjectResult(todos));
            }
        }
Exemplo n.º 4
0
        public TodoItemsListVm(ITodoItemsService todoItemsService)
        {
            this.todoItemsService = todoItemsService;

            // Firstly get all items, and after that watch to changes.
            todoItemsService.GetAll()
            .Select(items => items.Select(todoItem => new TodoItemVm(todoItem)))
            .Do(items => TodoItems.AddRange(items))
            .SelectMany(_ => todoItemsService.TodoItemAdded)
            .Subscribe(todoItem => TodoItems.Add(new TodoItemVm(todoItem)));

            this.WhenAnyValue(x => x.SelectedTodoItem)
            .Where(todoItem => todoItem != null)
            .Select(todoItem => todoItem.Model)
            .SelectMany(todoItem => todoItemsService.SetCurrentTodoItem(todoItem))
            .Subscribe();
        }
Exemplo n.º 5
0
        public StaticVm(ITodoItemsService todoItemsService)
        {
            this.todoItemsService = todoItemsService;

            var allItems = todoItemsService.GetAll()
                           .SelectMany(items => items);

            Observable.Merge(allItems, todoItemsService.TodoItemAdded)
            .Scan(this, (acc, todoItem) => {
                acc.TotalItems++;
                acc.TotalDuration   += todoItem.Duration;
                acc.AverageDuration += acc.TotalDuration / totalItems;
                acc.MinDuration      = Math.Min(acc.MinDuration, todoItem.Duration);

                acc.MaxDuration = Math.Min(acc.MaxDuration, todoItem.Duration);

                return(this);
            }).Subscribe();
        }
Exemplo n.º 6
0
 // GET: TodoItemModels
 public IActionResult Index()
 {
     return(View(_todoItemsService.GetAll()));
 }
 public IEnumerable <TodoItemModel> GetTodoItemModel()
 {
     return(_todoItemsService.GetAll());
 }