package io.vehiclehistory;

import android.content.Context;

import io.vehiclehistory.api.model.VehicleInput;
import io.vehiclehistory.api.model.VehicleResponse;
import io.vehiclehistory.database.SearchHistoryDb;

public class SaveSearchDelegate {

    SearchHistoryDb searchHistoryDb;

    public SaveSearchDelegate(Context context) {
        searchHistoryDb = new SearchHistoryDb(context);
    }

    public void saveSearch(VehicleInput input, VehicleResponse response) {
        searchHistoryDb.saveOrUpdateSearch(
                new Search(buildLabel(response), input.getPlate(), input.getVin(), input.getFirstRegistrationDate()));
    }

    private String buildLabel(VehicleResponse response) {
        return response.getVehicle().getName().getMake().toString() + " " + response.getVehicle().getName().getModel();
    }
}

@@ -54,16 +54,63 @@
 ntext;%0A%0A
+import io.vehiclehistory.api.OptionalProvider;%0A
 import i
@@ -150,16 +150,16 @@
 eInput;%0A
-
 import i
@@ -293,16 +293,30 @@
  %7B%0A%0A    
+private final 
 SearchHi
@@ -339,16 +339,69 @@
 storyDb;
+%0A    private final OptionalProvider optionalProvider;
 %0A%0A    pu
@@ -499,16 +499,74 @@
 ntext);%0A
+        optionalProvider = new OptionalProvider(context);%0A
     %7D%0A%0A 
@@ -886,69 +886,42 @@
 urn 
-response.getVehicle().getName().getMake().toString() + %22 %22 + 
+optionalProvider.getMakePlusModel(
 resp
@@ -941,28 +941,8 @@
 le()
-.getName().getModel(
 );%0A 

Fix SS1.