Example #1
0
        private IList <Taxon> GetTags()
        {
            FlatTaxonomy  category = taxonomyManager.GetTaxonomies <FlatTaxonomy>().Where(c => c.Name == TaxonomyName).FirstOrDefault();
            IList <Taxon> tags     = category.Taxa;

            return(tags);
        }
Example #2
0
        private Taxon GetTag(string tagName)
        {
            FlatTaxonomy category = taxonomyManager.GetTaxonomies <FlatTaxonomy>().Where(c => c.Name == TaxonomyName).FirstOrDefault();
            Taxon        tag      = category.Taxa.Where(t => t.UrlName == tagName).FirstOrDefault();

            return(tag);
        }
Example #3
0
 private void CreateFlatTaxonIfDoesntExists(SiteInitializer initializer, FlatTaxonomy taxonomy, string taxonName, string taxonTitle)
 {
     if (initializer.TaxonomyManager.GetTaxa <FlatTaxon>().Where(t => t.Name == taxonName).Count() == 0)
     {
         FlatTaxon taxon = null;
         taxon       = initializer.TaxonomyManager.CreateTaxon <FlatTaxon>();
         taxon.Name  = taxonName;
         taxon.Title = taxonTitle;
         taxonomy.Taxa.Add(taxon);
     }
 }
Example #4
0
        private FlatTaxonomyViewModel ToViewModel(FlatTaxonomy taxonomy)
        {
            var viewModel = new FlatTaxonomyViewModel();

            viewModel.Id   = taxonomy.Id;
            viewModel.Name = taxonomy.Title.Value;

            var taxaCount = this.taxaCounts
                            .FirstOrDefault(t => t.TaxonomyId == taxonomy.Id);

            viewModel.TaxaCount = taxaCount != null ? taxaCount.Count : 0;

            return(viewModel);
        }
        private static Taxon GetTagIfItExsistsOrCreateOneIfItDoesnt(string tagName, FlatTaxonomy tags, TaxonomyManager taxonomyManager)
        {
            Taxon tag = tags.Taxa.Where(t => t.Title.ToLower() == tagName.ToLower()).FirstOrDefault();

            if (tag == null)
            {
                tag = taxonomyManager.CreateTaxon<FlatTaxon>();

                SetTagProperties(tag, tagName);

                tag.Taxonomy = tags;

                taxonomyManager.SaveChanges();
            }

            return tag;
        }