private void LogSupplier(SupplierDocument supplierDocument) { var url = $"{Constants.ServerUrl}/api/resource/Sage 50 Export Log"; var resource = new Resource(url); resource.LogSupplier(supplierDocument); }
private Vendor CreateNewSupplier(SupplierDocument supplierDocument) { var supplier = Company.Factories.VendorFactory.Create(); if (supplierDocument != null && supplier != null) { try { supplier.ID = supplierDocument.VendorId; supplier.Email = supplierDocument.VendorEmail; supplier.Name = supplierDocument.SupplierName; supplier.WebSiteURL = supplierDocument.Website; supplier.IsInactive = supplierDocument.Disabled == 1; // AddAddresses(supplier, supplierDocument); // AddContacts(supplier, supplierDocument); supplier.Save(); Logger.Information("Supplier - {SupplierName} saved successfully", supplierDocument.SupplierName); } catch (Sage.Peachtree.API.Exceptions.ValidationException e) { Logger.Debug("Validation failed."); Logger.Debug(e.Message); Logger.Debug("{@Name} will be sent back to the queue", supplierDocument.Name); supplier = null; } catch (Sage.Peachtree.API.Exceptions.RecordInUseException) { supplier = null; Logger.Debug("Record is in use. {@Name} will be sent back to the queue", supplierDocument.Name); } catch (Exception e) { supplier = null; Logger.Debug(e, e.Message); Logger.Debug("{@E}", e); } } if (supplier == null) { Logger.Debug("Supplier data was null when trying to create Sage customer"); } return(supplier); }
public IRestResponse LogSupplier(SupplierDocument supplierDocument) { var log = new Log { document_name = supplierDocument.Name, export_date = DateTime.Now.ToString("yyyy-MM-dd"), document_date = DateTime.Now.ToString("yyyy-MM-dd"), document_type = supplierDocument.Doctype }; var request = new RestRequest(Method.POST); request.AddJsonBody(log); var response = _restClient.Execute(request); return(response); }