I am trying to create a simple application where I am querying against entity, getting results, running the results through a web service and getting the missing information. I am stuck at making updating the database with the new and updated results here is the code I have so far.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VetexV2
{
class Program
{
static void Main(string[] args)
{
string tid = "somevalue".ToString();
//webservice related
VertexWebService.PostalAddressType pat = new VertexWebService.PostalAddressType();
VertexWebService.VertexEnvelope env = new VertexWebService.VertexEnvelope();
VertexWebService.lookupTaxAreasRequest LTAR = new VertexWebService.lookupTaxAreasRequest();
VertexWebService.LookupTaxAreasWS60Client soap = new VertexWebService.LookupTaxAreasWS60Client();
VertexWebService.LoginType log = new VertexWebService.LoginType();
VertexWebService.TaxAreaLookupType talt = new VertexWebService.TaxAreaLookupType();
VertexWebService.TaxAreaRequestType tart1 = new VertexWebService.TaxAreaRequestType();
log.TrustedId = tid;
using (var db = new VetexV2.pesqlshareEntities1())
{
// query against the database
var query = from b in db.SalesOrder_FromSF
where b.VertexGeoCode.Length == 1
select new { address1 = b.Address1,
address2 = b.Address2,
city = b.JobCity,
state = b.StateCode,
zipcode = b.JobZip,
country = b.Country,
TAID = b.VertexGeoCode,
SalesforceOpportunity = b.SF_OpportunityID};
//parsing through the result
foreach (var item in query)
{
Console.WriteLine(item.address1);
Console.WriteLine(item.address2);
Console.WriteLine(item.city);
Console.WriteLine(item.state);
Console.WriteLine(item.zipcode);
Console.WriteLine(item.TAID);
pat.PostalCode = item.zipcode;
pat.MainDivision = item.state;
pat.Country = item.country;
pat.City = item.city;
pat.StreetAddress1 = item.address1;
pat.StreetAddress2 = item.address2;
talt.Item = pat;
tart1.TaxAreaLookup = talt;
env.Item = tart1;
env.Login = log;
env.Item = tart1;
LTAR.VertexEnvelope = env;
//using the info from above providing it to websevice
soap.Open();
soap.LookupTaxAreas60(ref LTAR.VertexEnvelope);
var reslt = ((VertexWebService.TaxAreaResponseType)(LTAR.VertexEnvelope.Item)).TaxAreaResult[0].taxAreaId.ToString();
Console.WriteLine(reslt);// displaying the missing or updated field on screen
Console.WriteLine("Press any Key");
// how do I put this updated field back into database ?
}
}
}
}
}