-
Notifications
You must be signed in to change notification settings - Fork 0
/
HomeController.cs
56 lines (47 loc) · 1.57 KB
/
HomeController.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using E4864.Models;
namespace E4864.Controllers
{
public class HomeController : Controller
{
static int counter;
public ActionResult Index() {
return View();
}
[HttpGet]
public ActionResult PageControlPartial() {
List<TabInfo> data = new List<TabInfo>();
data.Add(new TabInfo() {
Name = Guid.NewGuid().ToString(),
Text = "Tab",
Content = "Tab Content"
});
Session["TabData"] = data;
return PartialView("_PageControlPartial", data);
}
[HttpPost]
public ActionResult PageControlPartial(string command, string parameter) {
List<TabInfo> data = ((List<TabInfo>) Session["TabData"]) ?? new List<TabInfo>();
switch (command) {
case "ADD":
data.Add(new TabInfo() {
Name = Guid.NewGuid().ToString(),
Text = String.Format("Tab {0}", counter),
Content = String.Format("Tab {0} content", counter)
});
counter++;
break;
case "REMOVE":
if (data.Count > 1)
data.RemoveAll(info => info.Name == parameter);
break;
}
Session["TabData"] = data;
return PartialView("_PageControlPartial", data);
}
}
}