public static Boolean addorupdatePaymentFromUNMS(PaymentReadOnly upayment) { ClientReadOnly uclient = getclientbyid(Convert.ToDouble(upayment.ClientId)); string clientxeroid = ""; foreach (ClientAttributeReadOnly ca in uclient.Attributes) { if (ca.name == "xeroIdclient") { clientxeroid = ca.value; } ; } if (clientxeroid == "") { return(false); } string paymentxeroid = ""; foreach (PaymentAttributeReadOnly ca in upayment.Attributes) { if (ca.Name == "xeroIdinvoice") { paymentxeroid = ca.Value; } ; } if (paymentxeroid == "") { XeroHelper.updateorcreatexeropayment(upayment, clientxeroid); } return(true); }
public static Boolean addorupdateInvoiceFromUNMS(InvoiceReadOnly uinvoice) { ClientReadOnly uclient = getclientbyid(Convert.ToDouble(uinvoice.ClientId)); string clientxeroid = ""; foreach (ClientAttributeReadOnly ca in uclient.Attributes) { if (ca.name == "xeroIdclient") { clientxeroid = ca.value; } ; } if (clientxeroid == "") { clientxeroid = XeroHelper.updateorcreatexerocontact(uclient, ""); } string invoicexeroid = ""; foreach (InvoiceAttributeReadOnly ca in uinvoice.Attributes) { if (ca.Name == "xeroIdinvoice") { invoicexeroid = ca.Value; } ; } if (invoicexeroid == "") { XeroHelper.updateorcreatexeroinvoice(uinvoice, clientxeroid); } return(true); }
public static Boolean addorupdateClientFromUNMS(ClientReadOnly uclient) { // get latest client info uclient = getclientbyid(uclient.Id); string clientxeroid = ""; foreach (ClientAttributeReadOnly ca in uclient.Attributes) { if (ca.name == "xeroIdclient") { clientxeroid = ca.value; } ; } if (clientxeroid == "") { clientxeroid = XeroHelper.updateorcreatexerocontact(uclient, ""); } else { clientxeroid = XeroHelper.updateorcreatexerocontact(uclient, clientxeroid); } return(true); }
public static Boolean suspendServiceFromUNMS(ServiceReadOnly uservice) { ClientReadOnly uclient = getclientbyid(Convert.ToDouble(uservice.ClientId)); string pppoeid = ""; foreach (ClientAttributeReadOnly ca in uclient.Attributes) { if (ca.name == "PPPoE User") { pppoeid = ca.value; } ; } if (pppoeid != "") { MikrotikHelper.suspendpppoeuser(pppoeid); } return(true); }
public static string updateorcreatexerocontact(ClientReadOnly UClient, string clientxeroid) { XeroCoreApi xeroapp = getxeroapp(); Contact contact = new Contact(); if (clientxeroid != "") { contact = getXeroContact(clientxeroid); } if (UClient.CompanyName != "") { contact.Name = UClient.CompanyName; contact.FirstName = UClient.CompanyContactFirstName; contact.LastName = UClient.CompanyContactLastName; } else { contact.Name = UClient.FirstName + " " + UClient.LastName; contact.FirstName = UClient.FirstName; contact.LastName = UClient.LastName; } List <Phone> phonesl = new List <Phone>(); if (UClient.Contacts.FirstOrDefault().Phone != null) { Phone phn1 = new Phone(); phn1.PhoneType = Xero.Api.Core.Model.Types.PhoneType.Mobile; phn1.PhoneNumber = UClient.Contacts.FirstOrDefault().Phone; phonesl.Add(phn1); } contact.Phones = phonesl; List <Address> addl = new List <Address>(); Address add = new Address(); add.AddressType = Xero.Api.Core.Model.Types.AddressType.PostOfficeBox; add.AddressLine1 = UClient.Street1; add.AddressLine2 = UClient.Street2; add.City = UClient.City; add.PostalCode = UClient.ZipCode; addl.Add(add); contact.Addresses = addl; contact.EmailAddress = UClient.Contacts.FirstOrDefault().Email; Xero.Api.Core.Model.Contact contactreturned = xeroapp.Update(contact); // now update the crm with the xeroid if (clientxeroid == "") { UnmsClient UXClient = new UnmsClient(); ClientAttribute newUcrmAttribute = new ClientAttribute() { CustomAttributeId = 1, Value = contactreturned.Id.ToString() }; List <ClientAttribute> newlistattributes = new List <ClientAttribute>(); newlistattributes.Add(newUcrmAttribute); UXClient.attributes = newlistattributes; HTTPHelper.httpPatch("clients" + "/" + UClient.Id, UXClient); } return(contactreturned.Id.ToString()); }