public ActionResult Checkin(int?id) { if (Request.IsAjaxRequest()) { if (id != null) { Vehicle v = Garage.GetVehicle(id.Value); CheckInViewModel checkinviewmodel = new CheckInViewModel(); foreach (PropertyInfo p in typeof(CheckInViewModel).GetProperties()) { PropertyInfo modelproperty = typeof(CheckInViewModel).GetProperty(p.Name); PropertyInfo vehicleproperty = typeof(Vehicle).GetProperty(p.Name); if (vehicleproperty != null) { if (vehicleproperty.GetValue(v) != null) { modelproperty.SetValue(checkinviewmodel, vehicleproperty.GetValue(v)); } } } checkinviewmodel.vehicle = v; return(PartialView("Checkin", checkinviewmodel)); } else { return(PartialView("Create", new Vehicle())); } } return(RedirectToAction("Index")); }
// GET: Garage/Details/5 public ActionResult Details(int id = 0) { if (id != 0) { //Update the ParkPrice to current price garage.UpdateParkPrice(); return(View(garage.GetVehicle(id))); } return(RedirectToAction("Index")); }
// GET: Vehicles/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Vehicle vehicle = db.GetVehicle(id); if (vehicle == null) { return(HttpNotFound()); } return(View(vehicle)); }
public IHttpActionResult Get(int?id) { if (id == null) { return(BadRequest("ID cannot be null!")); } var vehicle = repo.GetVehicle(id.Value); if (vehicle == null) { return(NotFound()); } return(Ok(vehicle)); }
// GET api/values/5 public Vehicle Get(string regNr) { return(garage.GetVehicle(regNr)); }