Added creation of owner object. Vehicle addition now dynamic based on presence of VIN.
This commit is contained in:
45
BodyshopUploader/Utils/Queries/VehicleQueries.cs
Normal file
45
BodyshopUploader/Utils/Queries/VehicleQueries.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using GraphQL.Common.Request;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BodyshopUploader.Utils.Queries
|
||||
{
|
||||
public static class VehicleQueries
|
||||
{
|
||||
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static async Task<string> GetVehicleUuidByVin(string vin)
|
||||
{
|
||||
if (string.IsNullOrEmpty(vin))
|
||||
return null;
|
||||
|
||||
var r = new GraphQLRequest
|
||||
{
|
||||
Query = @"query QUERY_VEHICLE_BY_VIN($vin: String!) {
|
||||
vehicles(where: {v_vin: {_eq: $vin}}) {
|
||||
id
|
||||
}
|
||||
}",
|
||||
Variables = new
|
||||
{
|
||||
vin = vin
|
||||
}
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
var d = await Utils.GraphQL.ExecuteQuery(r);
|
||||
return d.vehicles?[0].id?.Value;
|
||||
|
||||
}
|
||||
catch (Exception Ex)
|
||||
{
|
||||
logger.Error(Ex, "Querying for vehicle by VIN failed.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user