Ejemplo n.º 1
0
        /* Public Methods. */

        public static void Save(wp_user user, params DailyOffer[] offers)
        {
            foreach (var offer in offers)
            {
                if (!PostCreationService.Contains(offer.DatabaseIdentifier))
                {
                    var terms        = offer.GetTerms();
                    var customFields = offer.GetCustomFields();

                    var id = PostCreationService.CreatePost(user, offer.Title, offer.DatabaseIdentifier, offer.Description, "code");

                    PostCreationService.CreatePostMetadata(id, customFields);
                    PostCreationService.CreatePostTaxonomy(id, terms);

                    log.DebugFormat("Created daily offer with ID <{0}> for merchant <{1}>.", offer.UniqueId, offer.Merchant);
                }
                else
                {
                    log.DebugFormat("Skipping daily offer with ID <{0}> for merchant <{1}>.", offer.UniqueId, offer.Merchant);
                }
            }
        }
        public static void Save(wp_user user, params Shop[] shops)
        {
            if (shops != null)
            {
                foreach (var shop in shops)
                {
                    if (!Contains(shop))
                    {
                        var id = PostCreationService.CreatePost(user, shop.Title, shop.DatabaseIdentifier, shop.Description, "shop");

                        PostCreationService.CreatePostMetadata(id, shop.GetCustomFields());
                        PostCreationService.CreatePostTaxonomy(id, new[] { new wp_term_relationship {
                                                                               term_taxonomy_id = TaxonomyCreationService.GetGeography(shop.Geography)
                                                                           } });

                        log.DebugFormat("Created shop with ID <{0}> for source <{1}>.", shop.UniqueId, shop.Source);
                    }
                    else
                    {
                        log.DebugFormat("Skipping shop with ID <{0}> for source <{1}>.", shop.UniqueId, shop.Source);
                    }
                }
            }
        }