public ActionResult Edit(int id, VehicleModel vehicleModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             VehicleModelHandler dbhandle = new VehicleModelHandler();
             if (dbhandle.AddOrUpdateVehicle(vehicleModel, id))
             {
                 ViewBag.Message = "Vehicle Details Updated Successfully";
             }
         }
         return(View());
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(VehicleModel vehicleModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             VehicleModelHandler dbhandle = new VehicleModelHandler();
             if (dbhandle.AddOrUpdateVehicle(vehicleModel))
             {
                 ViewBag.Message = "Vehicle Details Added Successfully";
                 ModelState.Clear();
             }
         }
         return(View());
     }
     catch
     {
         return(View());
     }
 }
        // **************** SEARCH OR FETCH VEHICLES *********************
        public ActionResult Index(FormCollection form)
        {
            VehicleModelHandler dbhandle = new VehicleModelHandler();

            ViewBag.RegistrationNumber = 0;

            //Retrieving registration number entered in the search field
            var id = Convert.ToInt32(form["RegistrationNumber"]);

            if (id == 0)
            {
                ModelState.Clear();
            }
            else
            {
                ViewBag.RegistrationNumber = id;
            }

            //if id == 0 we return all vehicles
            //else we return the vehicle which id is provided
            return(View(dbhandle.GetVehicles(id)));
        }
        // **************** EDIT/UPDATE VEHICLE *********************
        // GET: Vehicle/Edit/5
        public ActionResult Edit(int id)
        {
            VehicleModelHandler dbhandle = new VehicleModelHandler();

            return(View(dbhandle.GetVehicles(id).FirstOrDefault()));
        }