Inheritance: VehicleAdd
Exemple #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
            {
                // Attention - 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));
            }
        }
        public ActionResult AddVehicle(int? id)
        {
            // Attempt to get the associated object
            var a = m.ManufacturerGetById(id.GetValueOrDefault());

            if (a == null)
            {
                return HttpNotFound();
            }
            else
            {
                // Attention - 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);
            }
        }
 // GET: Vehicles/Create
 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);
 }
        // Attention 31 - Build the data for the HTML Form, for "add new" vehicle
        // GET: Vehicles/Create
        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));
        }