AssocAddEdit.Controllers.Manager.VehicleGetByIdWithDetail C# (CSharp) Метод

VehicleGetByIdWithDetail() публичный Метод

public VehicleGetByIdWithDetail ( int id ) : VehicleWithDetail
id int
Результат VehicleWithDetail
        public VehicleWithDetail VehicleGetByIdWithDetail(int id)
        {
            var o = ds.Vehicles.Include("Manufacturer.Country")
                .SingleOrDefault(v => v.Id == id);

            return Mapper.Map<VehicleWithDetail>(o);
        }

Usage Example

        // GET: Vehicles/Details/5
        public ActionResult Details(int?id)
        {
            // Attempt to get the matching object
            var o = m.VehicleGetByIdWithDetail(id.GetValueOrDefault());

            if (o == null)
            {
                return(HttpNotFound());
            }
            else
            {
                // Pass the object to the view
                return(View(o));
            }
        }