public async Task <TodoItemResource> Post([FromBody] TodoItemResource todoItem) { _logger.LogInformation("In front-end"); var httpClient = new HttpClient(); var client = new api.todoApi.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 }); }
public async Task <IEnumerable <TodoItemResource> > Get() { _logger.LogInformation("In front-end"); var httpClient = new HttpClient(); var client = new api.todoApi.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, WeatherForecast = new WeatherForecastResource { Date = (x.WeatherForecast?.Date ?? DateTimeOffset.MinValue).LocalDateTime, PostalCode = x.WeatherForecast?.PostalCode, Summary = x.WeatherForecast?.Summary, TemperatureC = x.WeatherForecast?.TemperatureC ?? 0, TemperatureF = x.WeatherForecast?.TemperatureF ?? 0 } }) .ToArray()); }