public ManufacturerBase GetManufacturerById(int id)
{
// Fetch the object using its identifier
// A DbSet collection supports the spiffy Find() method
// Way easier syntax than SingleOrDefault(),
// because it doesn't need a lambda expression
var fetchedObject = ds.Manufacturers.Find(id);
if (fetchedObject == null)
{
// Return null to the caller (who will also test the result)
return null;
}
else
{
// Create and deliver a view model object
return Mapper.Map<ManufacturerBase>(fetchedObject);
/*
var man = new ManufacturerBase();
man.Id = fetchedObject.Id;
man.Name = fetchedObject.Name;
man.Country = fetchedObject.Country;
man.YearStarted = fetchedObject.YearStarted;
return man;
*/
}
}