public GetAllManufacturersAsList ( ) : IEnumerable |
||
return | IEnumerable |
public IEnumerable<ManufacturerList> GetAllManufacturersAsList()
{
// Fetch from the persistent store
var fetchedObjects = ds.Manufacturers.OrderBy(man => man.Name);
// Prepare and return the view model objects
return Mapper.Map<IEnumerable<ManufacturerList>>(fetchedObjects);
/*
// Prepare the view model objects...
// Create a collection
var manufacturers = new List<ManufacturerList>();
// Go through the fetch results
foreach (var item in fetchedObjects)
{
var man = new ManufacturerList();
man.Id = item.Id;
man.Name = item.Name;
manufacturers.Add(man);
}
// Return the result
return manufacturers;
*/
}
// ############################################################ // // GET: /Vehicles/Create public ActionResult Create() { // Prepare the data for the view var addForm = new VehicleAddForm(); // If necessary, provide initial values for the form addForm.ModelYear = DateTime.Now.Year; // Add the 'select' UI control items addForm.Manufacturers = new SelectList(m.GetAllManufacturersAsList(), "Id", "Name"); return(View(addForm)); }