Exemplo n.º 1
0
        /// <summary>
        /// Add's Content Tiers to Destination Properties
        /// </summary>
        /// <param name="destinationData"></param>
        /// <param name="products"></param>
        private void AddContentTierToDestinationProperties(List <DLDestinationModel.Destination> destinationData, IQueryable <DLModel.Product> products)
        {
            if (products == null || !products.Any())
            {
                return;
            }

            if (destinationData == null || !destinationData.Any())
            {
                return;
            }

            foreach (DLModel.Product product in products)
            {
                if (product.ContentTiers != null && product.ContentTiers.Any())
                {
                    foreach (DLModel.ContentTier contentTier in product.ContentTiers)
                    {
                        foreach (DLDestinationModel.Destination des in destinationData)
                        {
                            if (!IsContentTierExistsInDestination(des, contentTier))
                            {
                                DLDestinationModel.Property property = contentTier.ToDataModel <DLModel.ContentTier, DLDestinationModel.Property>();
                                des.Properties.Add(property);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Add's the Categories to Destination Properties
 /// </summary>
 /// <param name="destinationData"></param>
 private static void AddCategoriesToDestinationProperties(List <DLDestinationModel.Destination> destinationData)
 {
     foreach (DLDestinationModel.Destination des in destinationData)  //verify each destination has categories . if yes then combine categories and properties.
     {
         if (des.Categories.Any())
         {
             foreach (DLDestinationModel.Category cat in des.Categories)
             {
                 DLDestinationModel.Property property = cat.ToDataModel <DLDestinationModel.Category, DLDestinationModel.Property>();
                 des.Properties.Add(property);
             }
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Checks the given content tier already added to Destination property or not.
        /// </summary>
        /// <param name="des"></param>
        /// <param name="contentTier"></param>
        /// <returns></returns>
        private bool IsContentTierExistsInDestination(DLDestinationModel.Destination des, DLModel.ContentTier contentTier)
        {
            DLDestinationModel.Property destProperty = des.Properties.FirstOrDefault(e => e.Name == "ContentTier" && e.Value == contentTier.Name);

            if (destProperty == null)
            {
                return(false);
            }

            bool brandsAreEquivalent = (destProperty.Brands.Count == destProperty.Brands.Count) &&
                                       !destProperty.Brands.Except(destProperty.Brands).Any();

            bool titlesAreEquivalent = (destProperty.TitleIds.Count == destProperty.TitleIds.Count) &&
                                       !destProperty.TitleIds.Except(destProperty.TitleIds).Any();


            return(brandsAreEquivalent && titlesAreEquivalent);
        }