Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
 // 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"));
 }
Exemplo n.º 3
0
        // 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));
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
 // GET api/values/5
 public Vehicle Get(string regNr)
 {
     return(garage.GetVehicle(regNr));
 }