Beispiel #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);
        }
Beispiel #2
0
 /// <summary>Overload to copy select data for database updates</summary>
 /// <param name="from"></param>
 public void CopyForDb(TaxConfiguration from)
 {
     ClientId        = from.ClientId;
     LastUpdateBy    = from.LastUpdateBy;
     Active          = from.Active;
     ItemType        = from.ItemType;
     ItemData        = from.ItemData;
     ItemDescription = from.ItemDescription;
     LastUpdateDate  = from.LastUpdateDate;
 }
Beispiel #3
0
        /// <summary>
        /// Test whether TaxConfiguration object refers to same profile item object passed in
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool Equals(TaxConfiguration other)
        {
            // Check whether the compared object is null.
            if (ReferenceEquals(other, null))
            {
                return(false);
            }

            // Check whether the compared object references the same data.
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(ProfileConfigId == other.ProfileConfigId);
        }
Beispiel #4
0
 /// <summary>Set updated profile config for response for reference (as applicable)</summary>
 /// <param name="updatedConfig"></param>
 public void SetUpdatedProfileConfig(TaxConfiguration updatedConfig)
 {
     UpdatedProfileConfig = updatedConfig;
 }