-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListExampleController.cs
66 lines (61 loc) · 1.78 KB
/
ListExampleController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using FeedbackMessages.Extensions;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using WebApp.MVC.Models;
namespace WebApp.MVC.Controllers
{
/// <summary>
/// リスト系コンポーネントのフォームバインディングサンプル
/// </summary>
public class ListExampleController : ExampleControllerBase
{
/// <summary>
/// Getリクエストを処理します。
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult Index()
{
var model = new ListExampleModel();
model.UserList.Add(new ListExampleModel.User()
{
UserId = "001",
UserName = "ユーザーA",
Age = 20
});
model.UserList.Add(new ListExampleModel.User()
{
UserId = "002",
UserName = "ユーザーB",
Age = 30
});
model.UserList.Add(new ListExampleModel.User()
{
UserId = "003",
UserName = "ユーザーC",
Age = 40
});
return View(model);
}
/// <summary>
/// Postリクエストを処理します。
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
public ActionResult Index(ListExampleModel model)
{
Debug.WriteLine(model.UserList.Count);
foreach (var user in model.UserList)
{
this.InfoMessage(user.UserId + ", " + user.UserName + ", " + user.Age);
}
return View(model);
}
}
}