Exemple #1
0
        public XElement BuildVendorElement(Vendor vendor)
        {
            var vendorElement = new XElement("vendor");

            var idElements = GetIdElements(vendor.Ids, IdXElementBuilder);

            if (idElements.Any())
            {
                vendorElement.Add(idElements);
            }

            if (string.IsNullOrEmpty(vendor.VendorName))
            {
                throw new AdfException("Vendor name is required for vendor.");
            }

            vendorElement.Add(new XElement("vendorname", vendor.VendorName));

            if (!string.IsNullOrEmpty(vendor.Url))
            {
                vendorElement.Add(new XElement("url", vendor.Url));
            }

            if (vendor.Contact != null)
            {
                vendorElement.Add(ContactXElementBuilder.BuildContactElement(vendor.Contact));
            }

            return(vendorElement);
        }
        public XElement BuildCustomerElement(Customer customer)
        {
            var customerElement = new XElement("customer");

            var idElements = GetIdElements(customer.Ids, IdXElementBuilder);

            if (idElements.Any())
            {
                customerElement.Add(idElements);
            }

            if (customer.Contact != null)
            {
                customerElement.Add(ContactXElementBuilder.BuildContactElement(customer.Contact));
            }

            if (customer.Timeframe != null)
            {
                customerElement.Add(GetTimeframeElement(customer.Timeframe));
            }

            if (!string.IsNullOrEmpty(customer.Comments))
            {
                customerElement.Add(new XElement("comments", customer.Comments));
            }

            return(customerElement);
        }
Exemple #3
0
        public XElement BuildProviderElement(Provider provider)
        {
            if (provider.Names == null || !provider.Names.Any())
            {
                throw new AdfException("A name is required for the provider.");
            }

            var providerElement = new XElement("provider");

            var idElements = GetIdElements(provider.Ids, IdXElementBuilder);

            if (idElements.Any())
            {
                providerElement.Add(idElements);
            }

            providerElement.Add(NameXElementBuilder.BuildNameElements(provider.Names));

            if (!string.IsNullOrEmpty(provider.Service))
            {
                providerElement.Add(new XElement("service", provider.Service));
            }

            if (!string.IsNullOrEmpty(provider.Url))
            {
                providerElement.Add(new XElement("url", provider.Url));
            }

            if (provider.Email != null)
            {
                providerElement.Add(EmailXElementBuilder.BuildEmailElement(provider.Email));
            }

            if (provider.Phone != null)
            {
                providerElement.Add(PhoneXElementBuilder.BuildPhoneElement(provider.Phone));
            }

            if (provider.Contact != null)
            {
                providerElement.Add(ContactXElementBuilder.BuildContactElement(provider.Contact));
            }

            return(providerElement);
        }