Example #1
0
        public override void Load(Dictionary<string, string> parameters)
        {
            base.Load(parameters);

            Title = "List";

            //// add items to an iList
            //iList list = new iList();

            //var menu = new iMenu();
            //menu.Header = "Items";

            //this.Items.Add(menu);

            carRepository = new CarRepository();
            var carList = carRepository.GetCars();
            // test comment

            if (parameters.ContainsKey(TEXTFIELD1))
            {
                if (carList.Exists(o => o.Name == parameters[TEXTFIELD1]))
                {
                    iApp.Session[CAR] = carList.Single(o => o.Name == parameters[TEXTFIELD1]);
                    this.CancelLoadAndNavigate(CAR_DETAIL.AppendPath(parameters[TEXTFIELD1]));
                    return;
                }
                     else
                    this.Title = BAD_CAR;
            }

            // Make the menu
            var menu = new iMenu();
            menu.Header = ITEMS;

            // Add the cars to the list
            foreach (var car in carList)
            {
                menu.Items.Add(new iItem()
                {
                    Text = car.Name,
                    Subtext = car.VehicleClass.ToString(),
                    Link = new iFactr.Core.Controls.Link(CAR_DETAIL.AppendPath(car.Name))
                });
            }
            this.Items.Add(menu);

            var fieldSet = new Fieldset();
            fieldSet.Header = FIELDS;

            var textField = (new TextField(TEXTFIELD1)
            {
                Label = TF1,
                Text = parameters.ContainsKey(TEXTFIELD1) ? parameters[TEXTFIELD1] : string.Empty
            });

            // Validation
            textField.Validate = (value, errorMsg, args) =>
            {
                if (!carList.Exists(o => o.Name == value))
                {
                    errorMsg = BAD_CAR;
                    textField.BrokenRules.Add(BAD_CAR);
                }
            };
            fieldSet.Fields.Add(textField);
            this.Items.Add(fieldSet);
            this.ActionButtons.Add(new SubmitButton(SAVE, CAR_LIST));
        }
Example #2
0
        public override void Clear()
        {
            base.Clear();

            carRepository = null;
        }