Updated graphql package and changed insert job query to upsert BOD-198.
This commit is contained in:
@@ -1,22 +1,24 @@
|
||||
using GraphQL.Client;
|
||||
using GraphQL.Common.Request;
|
||||
using GraphQL.Common.Response;
|
||||
using GraphQL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using GraphQL.Client.Http;
|
||||
using GraphQL.Client.Serializer.Newtonsoft;
|
||||
|
||||
namespace BodyshopPartner.Utils
|
||||
{
|
||||
public static class GraphQL
|
||||
{
|
||||
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static GraphQLClient CreateGQLClient()
|
||||
|
||||
public static GraphQLHttpClient CreateGQLClient()
|
||||
{
|
||||
var graphQLClient = new GraphQLClient("https://bodyshop-dev-db.herokuapp.com/v1/graphql");
|
||||
graphQLClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + Utils.Auth.authlink.FirebaseToken);
|
||||
var graphQLClient = new GraphQLHttpClient("https://bodyshop-dev-db.herokuapp.com/v1/graphql", new NewtonsoftJsonSerializer());
|
||||
|
||||
graphQLClient.HttpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + Utils.Auth.authlink.FirebaseToken);
|
||||
return graphQLClient;
|
||||
}
|
||||
|
||||
@@ -25,9 +27,10 @@ namespace BodyshopPartner.Utils
|
||||
using (var g = Utils.GraphQL.CreateGQLClient())
|
||||
{
|
||||
logger.Trace("Firing GQL Query: {0} {1}", r.Query.ToString(), r.Variables);
|
||||
var graphQLResponse = await g.PostAsync(r);
|
||||
var graphQLResponse = await g.SendQueryAsync<dynamic>(r);
|
||||
if (graphQLResponse.Errors == null)
|
||||
{
|
||||
|
||||
//logger.Trace("GQL Response: {0}", graphQLResponse.Data);
|
||||
return graphQLResponse.Data;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
||||
using BodyshopPartner.Utils;
|
||||
using BodyshopPartner.Models;
|
||||
using BodyshopPartner.Utils.Growls;
|
||||
using GraphQL.Common.Request;
|
||||
using GraphQL;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using ToastNotifications.Messages;
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace BodyshopPartner.Utils
|
||||
newJob.est_data.vehicleid = vehuuid;
|
||||
}
|
||||
|
||||
if (await Utils.Queries.JobsQueries.GetJobUuidByClmNo(item.Job.clm_no?.Value ?? ""))
|
||||
if (await Utils.Queries.JobsQueries.CheckSupplementByClaimNo(item.Job.clm_no?.Value ?? ""))
|
||||
{
|
||||
newJob.issupplement = true;
|
||||
};
|
||||
@@ -141,19 +141,21 @@ namespace BodyshopPartner.Utils
|
||||
var r = new GraphQLRequest
|
||||
{
|
||||
Query = @"
|
||||
mutation INSERT_AVAILABLE_JOB($jobInput: [available_jobs_insert_input!]!) {
|
||||
insert_available_jobs(objects: $jobInput) {
|
||||
returning {
|
||||
id
|
||||
}
|
||||
}
|
||||
}",
|
||||
mutation INSERT_AVAILABLE_JOB($jobInput: [available_jobs_insert_input!]!) {
|
||||
insert_available_jobs(objects: $jobInput, on_conflict: {constraint: available_jobs_clm_no_bodyshopid_key, update_columns: [clm_amt, cieca_id, est_data, issupplement, ownr_name, source_system, supplement_number, vehicle_info]}) {
|
||||
returning {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
",
|
||||
Variables = new
|
||||
{
|
||||
jobInput = newJob
|
||||
jobInput = newJob,
|
||||
}
|
||||
};
|
||||
|
||||
//cieca_id, est_data, issupplement, jobid, ownr_name, source_system, supplement_number, vehicle_info
|
||||
try
|
||||
{
|
||||
var d = await Utils.GraphQL.ExecuteQuery(r);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using GraphQL.Common.Request;
|
||||
using GraphQL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -11,7 +11,7 @@ namespace BodyshopPartner.Utils.Queries
|
||||
{
|
||||
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static async Task<bool> GetJobUuidByClmNo(string ClmNo)
|
||||
public static async Task<bool> CheckSupplementByClaimNo(string ClmNo)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ClmNo))
|
||||
return false;
|
||||
@@ -19,9 +19,9 @@ namespace BodyshopPartner.Utils.Queries
|
||||
var r = new GraphQLRequest
|
||||
{
|
||||
Query = @"query QUERY_JOB_BY_CLM_NO($clm_no: String!) {
|
||||
jobs(where: {clm_no: {_eq: $clm_no}}) {
|
||||
id
|
||||
}
|
||||
jobs(where: {clm_no: {_eq: $clm_no}}) {
|
||||
id
|
||||
}
|
||||
}",
|
||||
Variables = new
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using GraphQL.Common.Request;
|
||||
using GraphQL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
Reference in New Issue
Block a user