public static WeatherForecastResponseModel ToResponseModel(WeatherForecastExtended wf)
 {
     return(new WeatherForecastResponseModel
     {
         Summary = wf.Summary,
         CreationTime = wf.CreationTime
     });
 }
Exemple #2
0
 public async Task <IActionResult> AddData([FromBody] WeatherForecast forecast)
 {
     try
     {
         WeatherForecastExtended weatherForecastExtendedModel = Factory.ToExtendedModel(forecast);
         weatherForecasts.Add(weatherForecastExtendedModel);
         if (weatherForecasts.Count > 10)
         {
             return(Redirect("Cleanup"));
         }
         return(Ok(await Task.FromResult(Factory.ToResponseModel(weatherForecastExtendedModel))));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }