1+ //**********************************************************************************
2+ //* テスト・コントローラー
3+ //**********************************************************************************
4+
5+ // テスト・コントローラーなので、必要に応じて流用 or 削除して下さい。
6+
7+ //**********************************************************************************
8+ //* クラス名 :ValuesController
9+ //* クラス日本語名 :疎通確認用
10+ //*
11+ //* 作成日時 :-
12+ //* 作成者 :生技
13+ //* 更新履歴 :
14+ //*
15+ //* 日時 更新者 内容
16+ //* ---------- ---------------- -------------------------------------------------
17+ //* 2018/09/07 西野 大介 新規作成
18+ //**********************************************************************************
19+
20+ using System ;
21+ using System . Linq ;
22+ using System . Collections . Generic ;
23+
24+ using Microsoft . AspNetCore . Mvc ;
25+ using Microsoft . AspNetCore . Cors ;
26+
27+ namespace ReactReduxTemplate . Controllers
28+ {
29+ [ ApiController ]
30+ [ Route ( "api/[controller]/[action]" ) ]
31+ public class SampleDataController : ControllerBase
32+ {
33+ /// <summary>Summaries</summary>
34+ private static string [ ] Summaries = new [ ]
35+ {
36+ "Freezing" , "Bracing" , "Chilly" , "Cool" , "Mild" , "Warm" , "Balmy" , "Hot" , "Sweltering" , "Scorching"
37+ } ;
38+
39+ /// <summary>
40+ /// GET api/sampledata/weatherforecasts?startDateIndex=1
41+ /// </summary>
42+ /// <param name="startDateIndex">int</param>
43+ /// <returns>IEnumerable(WeatherForecast)</returns>
44+ [ HttpGet ( ) ]
45+ public IEnumerable < WeatherForecast > WeatherForecasts ( int startDateIndex )
46+ {
47+ var rng = new Random ( ) ;
48+ return Enumerable . Range ( 1 , 5 ) . Select ( index => new WeatherForecast
49+ {
50+ DateFormatted = DateTime . Now . AddDays ( index + startDateIndex ) . ToString ( "d" ) ,
51+ TemperatureC = rng . Next ( - 20 , 55 ) ,
52+ Summary = Summaries [ rng . Next ( Summaries . Length ) ]
53+ } ) ;
54+ }
55+
56+ /// <summary>WeatherForecast</summary>
57+ public class WeatherForecast
58+ {
59+ public string DateFormatted { get ; set ; }
60+ public int TemperatureC { get ; set ; }
61+ public string Summary { get ; set ; }
62+
63+ public int TemperatureF
64+ {
65+ get
66+ {
67+ return 32 + ( int ) ( TemperatureC / 0.5556 ) ;
68+ }
69+ }
70+ }
71+ }
72+ }
0 commit comments