Added creation of owner object. Vehicle addition now dynamic based on presence of VIN.

This commit is contained in:
Patrick Fic
2020-01-29 14:12:39 -08:00
parent 786b96b3bc
commit 9d9064d25f
5 changed files with 100 additions and 18 deletions

View 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;
}
}
}
}