public override void Load(Dictionary<string, string> parameters) { // var catList = new CatRepository ().GetCats (); catRepo = new CatRepository (); var catList = catRepo.GetCats (); if (parameters.ContainsKey ("textField1")) { if (catList.Exists (o => o.Name == parameters ["textField1"])) { iApp.Session ["Cat"] = catList.Single (o => o.Name == parameters ["textField1"]); this.CancelLoadAndNavigate ("CatDetail".AppendPath (parameters ["textField1"])); return; } else { this.Title = "<bad cat>"; } } // Title = "Cats"; var menu = new iMenu (); menu.Header = "Items"; foreach (var c in catList) { menu.Items.Add (new iItem () { Text = c.Name, Subtext = c.Breed.ToString(), Link = new Link ("CatDetail".AppendPath(c.Name)) }); } this.Items.Add (menu); var fieldSet = new Fieldset (); fieldSet.Header = "Fields"; // fieldSet.Fields.Add (new TextField ("textField1") { // Label = "TF1", // Text = parameters.ContainsKey("textField1") ? parameters ["textField1"] : string.Empty // }); var textField = (new TextField ("textField1") { Label = "TF1", Text = parameters.ContainsKey("textField1") ? parameters ["textField1"] : string.Empty }); textField.Validate = (value, errorMsg, args) => { if (!catList.Exists (o => o.Name == value)) { errorMsg = "bad cat"; textField.BrokenRules.Add("bad cat"); } }; fieldSet.Fields.Add (textField); this.Items.Add (fieldSet); this.ActionButtons.Add (new SubmitButton ("Save", "CatList")); }
public override void Clear() { base.Clear (); catRepo = null; }