Exemplo n.º 1
0
        /// <summary>
        /// Converts configuration into api response
        /// </summary>
        /// <param name="cpConfig"></param>
        /// <param name="includeInternal"></param>
        /// <returns>ProfileConfigResponse object</returns>
        public TaxConfigResponse Convert(TaxConfiguration cpConfig, bool includeInternal)
        {
            if (cpConfig == null)
            {
                return(this);  // return empty object not null (as calling method expects either a valid object or exception)
            }

            ProfileConfigId = cpConfig.ProfileConfigId;
            ProfileIds      = cpConfig.ProfileIds;
            if (ProfileIds != null && ProfileIds.Count > 1)
            {
                ProfileIds.Sort();
            }
            ClientId = cpConfig.ClientId;
            Active   = cpConfig.Active;
            ItemType = cpConfig.ItemType.ToString("g");

            // If permitted to see internal data, always return LastUpdateBy
            // else if last update is avalarian, return defined default mask value (protect internal users from external clients)
            // else return LastUpdateBy (if not-avalarian, client can see who updated the configuration last)

            if (includeInternal)
            {
                LastUpdateBy = cpConfig.LastUpdateBy;
            }
            else
            {
                LastUpdateBy = cpConfig.LastUpdateBy.ToLower().Contains("avalara") ? LastUpdateByAvaMask : cpConfig.LastUpdateBy;
            }

            ProfileConfigId = cpConfig.ProfileConfigId;
            Description     = cpConfig.ItemDescription;

            if (cpConfig.ItemType == ClientProfileItemTypes.Configuration)
            {
                Settings = cpConfig.ProcureConfigSettings(includeInternal);
            }
            else if (cpConfig.ItemType == ClientProfileItemTypes.Exclusion)
            {
                Exclusions = cpConfig.ProcureConfigExclusions();
            }
            else if (cpConfig.ItemType == ClientProfileItemTypes.Bundle)
            {
                Bundles = cpConfig.ProcureConfigBundles();
            }
            else if (cpConfig.ItemType == ClientProfileItemTypes.Nexus)
            {
                Nexus = cpConfig.ProcureConfigNexus();
            }
            else if (cpConfig.ItemType == ClientProfileItemTypes.Override)
            {
                Overrides = cpConfig.ProcureConfigOverrides();
            }

            return(this);
        }
Exemplo n.º 2
0
 /// <summary>SetProfileIds</summary>
 public void AddProfileId(int profileId)
 {
     ProfileIds.Add(profileId);
 }