private string InsertSuiteRegistration(CreateRegistrationRequest registerRequest, string logId) { var suiteWrapper = new SuiteWrapper(); suitesessionId = suiteWrapper.Login().GetAwaiter().GetResult(); var request = new InsertRequest(); request.SessionId = suitesessionId; request.ModuleName = "reg_Registration"; request.Entity = registerRequest; var resp = suiteWrapper.Insert(request).GetAwaiter().GetResult(); if (resp != null) { UpdateContactRegistration(resp.Id, registerRequest.Contact_id, logId); common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "Inserted Suite Registration successfully Id: " + resp.Id, Name = "InsertSuiteRegistration", Entity_c = "Registration" }, logId); SuiteWrapper.WriteTraceLog("InsertSuiteRegistration", "Inserted Suite Registration successfully Id: " + resp.Id); return(resp.Id); } return(null); }
public CreateTraceLogResponse InsertSuiteAmIntegrationLogDetail(CreateTraceLogRequest result_page, string logId) { var suiteWrapper = new SuiteWrapper(); suitesessionId = suiteWrapper.Login().GetAwaiter().GetResult(); var tracelogrequest = new CreateTraceLogRequest(); tracelogrequest.Name = result_page.Name; tracelogrequest.Description = result_page.Description; tracelogrequest.Entity_c = result_page.Entity_c; tracelogrequest.Sync_date_c = Convert.ToDateTime(DateTime.Now.ToShortDateString()); tracelogrequest.Integration_summary_ida = logId; if (!string.IsNullOrEmpty(result_page.Email_c)) { tracelogrequest.Email_c = result_page.Email_c; } var request_Integration_Detail = new InsertRequest { SessionId = suitesessionId, ModuleName = "pndl_AM_Integration_Detail", Entity = tracelogrequest }; suiteWrapper.Insert(request_Integration_Detail).GetAwaiter().GetResult(); return(null); }
private void InsertSuiteAddress(AMCustomer.AMAddress addrDetails, SuiteContact suiteContact, string logId) { try { var suiteWrapper = new SuiteWrapper(); suitesessionId = suiteWrapper.Login().GetAwaiter().GetResult(); var addressrequest = new CreateAddressRequest(); addressrequest.Name = suiteContact.Name; addressrequest.Country = addrDetails.Country_code; addressrequest.Address1 = addrDetails.Street_address; addressrequest.City = addrDetails.Locality; addressrequest.Client_number_c = suiteContact.Client_number_c; addressrequest.State = addrDetails.Region; addressrequest.Zip = addrDetails.Postal_code; if (addrDetails.Type == "home" || addrDetails.Type == null) { addressrequest.Shipping_address = true; } if (addrDetails.Type == "billing") { addressrequest.Billing_address = true; } addressrequest.Contacts_add1_addresses_1contacts_ida = suiteContact.Id; var request = new InsertRequest(); request.SessionId = suitesessionId; request.ModuleName = "add1_Addresses"; request.Entity = addressrequest; var resp = suiteWrapper.Insert(request).GetAwaiter().GetResult(); if (resp == null) { SuiteWrapper.WriteTraceLog("InsertSuiteAddress", "Error : In updating Address for client Number"); } } catch (Exception ex) { common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "Error : " + ex.Message, Name = "InsertSuiteAddress", Entity_c = "Registration" }, logId); SuiteWrapper.WriteTraceLog("InsertSuiteAddress", "Error : " + ex.Message); } }
private string InsertSuiteContact(JToken AMCustomers_Result, string logId) { try { // Based on Email-id search Customer Record and update record var custEmail = Convert.ToString(AMCustomers_Result.SelectToken("preferred_email")); var suiteContact = common.GetSuiteContactIDByEmail(custEmail, logId); var internalID = string.Empty; if (suiteContact.Count() > 0) { if (suiteContact.Count() == 1) { foreach (EntryListArray contact in suiteContact) { internalID = contact.Id; common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "Only one record exist for email id :'" + custEmail + "' in Suite", Name = "InsertSuiteContact", Entity_c = "Customer" }, logId); SuiteWrapper.WriteTraceLog("InsertSuiteContact", "Only one record exist for email id :'" + custEmail + "' in Suite"); } } else { if (custEmail != "*****@*****.**") { foreach (var k in suiteContact) { internalID = k.Id; common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Email_c = custEmail, Description = "Multiple records exist for email id :'" + custEmail + "' in Suite: ", Name = "InsertSuiteContact", Entity_c = "Customer" }, logId); SuiteWrapper.WriteTraceLog("InsertSuiteContact", "Multiple records exist for email id :'" + custEmail + "' in Suite: "); } } } } else { // Create NetSuite Customer Record var suiteWrapper = new SuiteWrapper(); suitesessionId = suiteWrapper.Login().GetAwaiter().GetResult(); var contactrequest = new CreateContactRequest { Email = Convert.ToString(AMCustomers_Result.SelectToken("preferred_email")), Phone = Convert.ToString(AMCustomers_Result.SelectToken("phone_number")), FirstName = Convert.ToString(AMCustomers_Result.SelectToken("given_name")), LastName = Convert.ToString(AMCustomers_Result.SelectToken("family_name")), Salutation = Convert.ToString(AMCustomers_Result.SelectToken("title")), Fax = Convert.ToString(AMCustomers_Result.SelectToken("fax_number")), Comments = Convert.ToString(AMCustomers_Result.SelectToken("notes")), ContactType = "Individual", CompanyName = Convert.ToString(AMCustomers_Result.SelectToken("company_name")), AMCustomerId = Convert.ToString(AMCustomers_Result.SelectToken("row_id")), Approvalestatus = "Pending_Approval" }; var request = new InsertRequest { SessionId = suitesessionId, ModuleName = "Contacts", Entity = contactrequest }; var resp = suiteWrapper.Insert(request).GetAwaiter().GetResult(); common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "Customer Inserted to Suite successfully for Id :" + resp.Id, Name = "InsertSuiteContact", Entity_c = "Customer" }, logId); SuiteWrapper.WriteTraceLog("InsertSuiteContact", "Customer Inserted to Suite successfully for Id :" + resp.Id); return(resp.Id); } } catch (Exception ex) { common.InsertSuiteAmIntegrationLogDetail(new CreateTraceLogRequest() { Description = "Error : " + ex.Message, Name = "InsertSuiteContact", Entity_c = "Customer" }, logId); SuiteWrapper.WriteTraceLog("InsertSuiteContact", "Error : " + ex.Message); } return(""); }