Esempio n. 1
0
        public async Task <IEnumerable <TodoItemResource> > Get([FromServices] api.todoApi.ITodoApiClient apiClient)
        {
            _logger.LogInformation("In front-end");
            var todoItems = await apiClient.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());
        }
Esempio n. 2
0
        public async Task <TodoItemResource> Post([FromBody] TodoItemResource todoItem, [FromServices] api.todoApi.ITodoApiClient apiClient)
        {
            _logger.LogInformation("In front-end");

            var toSave = new TodoItem
            {
                Name = todoItem.Name
            };
            var result = await apiClient.TodoItemsAsync(toSave);

            return(new TodoItemResource
            {
                Id = result.Id,
                IsComplete = result.IsComplete,
                Name = result.Name
            });
        }