public string Create(Vehicle vehicle)
 {
     string msg = "";
     if (ModelState.IsValid) {
         repository.SaveVehicle(vehicle);
         msg = "Fordonet är tillagt i databasen.";
     }
     else {
         msg = "Ett fel inträffade, försök igen.";
     }
     return msg;
 }
 public void SaveVehicle(Vehicle vehicle)
 {
     if (vehicle.Id == 0)
     {
         context.Vehicles.Add(vehicle);
     }
     else
     {
         Vehicle dbPost = context.Vehicles.Find(vehicle.Id);
         if (dbPost != null)
         {
             dbPost.RegNr = vehicle.RegNr;
             dbPost.Description = vehicle.Description;
         }
     }
     context.SaveChanges();
 }
 public ActionResult Create()
 {
     Vehicle vehicle = new Vehicle();
     return PartialView(vehicle);
 }