private async Task <IEnumerable <TodoItem> > GetRandomTodoItems() { var rnd = new Random(); var httpClient = new HttpClient(); var client = new api.clients.TodoApiClient("https://localhost:5005", httpClient); var todoItems = await client.TodoItemsAllAsync(); return(todoItems.Take(rnd.Next(0, todoItems.Count()))); }
public async Task <IEnumerable <TodoItemResource> > Get() { _logger.LogInformation("In front-end"); var httpClient = new HttpClient(); var client = new api.clients.TodoApiClient("https://localhost:5005", httpClient); var todoItems = await client.TodoItemsAllAsync(); return(todoItems.Select(x => new TodoItemResource { Id = x.Id, IsComplete = x.IsComplete, Name = x.Name }) .ToArray()); }
public async Task <TodoItemResource> Post([FromBody] TodoItemResource todoItem) { _logger.LogInformation("In front-end"); var httpClient = new HttpClient(); var client = new api.clients.TodoApiClient("https://localhost:5005", httpClient); var toSave = new TodoItem { Name = todoItem.Name }; var result = await client.TodoItemsAsync(toSave); return(new TodoItemResource { Id = result.Id, IsComplete = result.IsComplete, Name = result.Name }); }