More working tests.
[castle.git] / Samples / MonoRail / JSGenExample / Controllers / HomeController.cs
blobad2ddb839e4637c3051ce7665044ed8fbdb6b4b8
1 namespace JSGenExample.Controllers
3 using Castle.MonoRail.Framework;
4 using Castle.MonoRail.Framework.Helpers;
5 using JSGenExample.Models;
7 [Layout("default"), Rescue("generalerror")]
8 public class HomeController : SmartDispatcherController
10 private const int PageSize = 5;
12 public void Index()
14 PropertyBag["customers"] = PaginationHelper.CreatePagination<Customer>(this, Customers, PageSize);
17 /// <summary>
18 /// Invoked by Ajax
19 /// </summary>
20 public void NewCustomer()
22 // Here, the NewCustomer.njs will be "rendered"
25 /// <summary>
26 /// Invoked by Ajax
27 /// </summary>
28 public void AddCustomer([DataBind("customer")] Customer customer)
30 // Pretend to save it
31 // Here, the AddCustomer.njs will be "rendered"
33 PropertyBag["customer"] = customer;
36 /// <summary>
37 /// Just to mimic a persistent storage
38 /// </summary>
39 protected Customer[] Customers
41 get
43 if (!Session.Contains("items"))
45 Session["items"] = new Customer[]
47 new Customer(1, "Apple", "contact@apple.com"),
48 new Customer(2, "Google", "contact@google.com"),
49 new Customer(3, "Microsoft", "contact@ms.com"),
50 new Customer(4, "ChangeCorporation", "contact@changecorporation.com.au"),
51 new Customer(5, "Castle Stronghold", "contact@castlestronghold.com"),
52 new Customer(6, "Fox Networks", "contact@fox-intl.com"),
53 new Customer(7, "Cisco", "contact@cisco.com"),
54 new Customer(8, "Linksys", "contact@linksys.com"),
55 new Customer(9, "Siemens", "contact@siemens.com"),
56 new Customer(10, "Toshiba", "contact@toshiba.com"),
57 new Customer(11, "Dell", "contact@dell.com"),
61 return (Customer[]) Session["items"];