Exemple #1
0
        public void LoadData()
        {
            Filter            = FilterItem.InitFilters();
            ProtectionClasses = ProtectionClass.FromDatabase();

            TaxonFilterItems       = Load.FromFile <TaxonFilterItem>("TaxonFilterItems.json");
            Taxa                   = Load.FromFile <Taxon>("Taxa.json").OrderBy(i => i.LocalName).ThenBy(i => i.TaxonName).ToList();
            TaxonImages            = Load.FromFile <TaxonImage>("TaxonImages.json");
            TaxonImageTypes        = Load.FromFile <TaxonImageType>("TaxonImageTypes.json");
            TaxonProtectionClasses = Load.FromFile <TaxonProtectionClass>("TaxonProtectionClasses.json");
            TaxonSynonyms          = Load.FromFile <TaxonSynonym>("TaxonSynonyms.json");

            foreach (var taxon in Taxa)
            {
                taxon.Images        = TaxonImages.Where(i => i.TaxonId == taxon.TaxonId).OrderBy(i => i.Index).ToList();
                taxon.ImageTypes    = TaxonImageTypes.Where(i => i.TaxonId == taxon.TaxonId && i.TaxonTypeId == taxon.TaxonTypeId).ToList();
                taxon.TotalCriteria = TaxonFilterItems.Where(i => i.TaxonId == taxon.TaxonId && i.TaxonTypeId == taxon.TaxonTypeId).Count();
            }
            foreach (var fi in TaxonFilterItems)
            {
                if (fi.ListSourceJson != null)
                {
                    foreach (string lsj in fi.ListSourceJson)
                    {
                        if (!TaxonImages.Select(ti => ti.Title).ToList().Contains(lsj.Trim()))
                        {
                            TaxonImages.Add(new TaxonImage {
                                Title = lsj.Trim(), ImageId = Guid.NewGuid().ToString()
                            });
                        }
                    }
                }
            }
            TaxonOrders = Taxa.Where(i => i.HasDiagnosis).Select(i => new { i.OrderName, i.OrderLocalName }).Distinct().Select(i => new TaxonOrder()
            {
                OrderName = i.OrderName, OrderLocalName = i.OrderLocalName
            }).ToList();
        }