public ActionResult Edit([Bind(Include = "Id,RegNr, Owner, Color, VehicleType, NumberOfWheels, InTime, OutTime")] Vehicle newVehicle)
        {
            if (ModelState.IsValid && Request.IsAjaxRequest())
            {
                Garage.EditVehicle(newVehicle);

                return(Json(new { type = true, message = "Item Edited!" }));
            }

            return(RedirectToAction("Index"));
        }
Exemple #2
0
 public ActionResult Edit([Bind(Include = "Id,Color,RegNr,TypeId,OwnerId")] Vehicle vehicle)
 {
     if (ModelState.IsValid)
     {
         db.EditVehicle(vehicle);
         return(RedirectToAction("Index"));
     }
     ViewBag.OwnerId = new SelectList(db.GetOwners(), "Id", "Name", vehicle.OwnerId);
     ViewBag.TypeId  = new SelectList(db.GetVehicleTypes(), "Id", "Name", vehicle.TypeId);
     return(View(vehicle));
 }
Exemple #3
0
        public IHttpActionResult Put(int?id, [FromBody] VehicleViewModel vm)
        {
            if (id == null || id != vm.ID || !ModelState.IsValid)
            {
                return(BadRequest("Something went horribly wrong! " + vm));
            }

            var vehicle = repo.GetVehicle(id.Value);

            if (vehicle == null)
            {
                return(NotFound());
            }

            repo.EditVehicle(vm);

            return(Ok("Vehicle Edited Successfully! " + vm));
        }