示例#1
0
        public ActionResult AddVehicle(int?id)
        {
            // Attempt to get the associated object
            var a = m.ManufacturerGetById(id.GetValueOrDefault());

            if (a == null)
            {
                return(HttpNotFound());
            }
            else
            {
                // Add vehicle for a known manufacturer
                // We send the manufacturer identifier to the form
                // There, it is hidden... <input type=hidden
                // We also pass on the name, so that the browser user
                // knows which manufacturer they're working with

                // Create and configure a form object
                var o = new VehicleAddForm();
                o.ManufacturerId   = a.Id;
                o.ManufacturerName = a.Name;

                return(View(o));
            }
        }
示例#2
0
        public ActionResult Create()
        {
            // Create a form
            var form = new VehicleAddForm();

            // Configure the SelectList for the item-selection element on the HTML Form
            form.ManufacturerList = new SelectList(m.ManufacturerGetAll(), "Id", "Name");

            return(View(form));
        }