public IActionResult Get() { var result = _todoItemsService.GetAll(); if (result?.Any() == false) { return(NoContent()); } return(Ok(result)); }
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)); } }
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(); }
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(); }
// GET: TodoItemModels public IActionResult Index() { return(View(_todoItemsService.GetAll())); }
public IEnumerable <TodoItemModel> GetTodoItemModel() { return(_todoItemsService.GetAll()); }