//Get the Variant id's (Lily) private List <long?> GetVariantIds(string variant) { //possibility to set variable to N/A because some plants have no variants if (variant == NoVariant) { return(new List <long?> { null }); } var variants = _context.TfgsvVariant.ToList().Where(v => PlantenParser.ParseSearchText(v.Variantnaam) .Contains(PlantenParser.ParseSearchText(variant))) .Select(v => v.VariantId) .Cast <long?>() .ToList(); //add null to the list to find plants without variants if (variant == string.Empty) { variants.Add(null); } return(variants); }
//Search the plants based on Id and Name(Lily) private List <Plant> SearchPlantsWithTgsvAndName(List <long> typeIds, List <long> familyIds, List <long> genusIds, List <long> speciesIds, List <long?> variantIds, string name) { return(_context.Plant .Include(p => p.Abiotiek) .Include(p => p.AbiotiekMulti) .Include(p => p.BeheerMaand) .Include(p => p.Commensalisme) .Include(p => p.CommensalismeMulti) .Include(p => p.ExtraEigenschap) .Include(p => p.Fenotype) .Include(p => p.Foto) .ToList() .Where(p => variantIds.Contains(p.VariantId) && speciesIds.Contains((long)p.SoortId !) && genusIds.Contains((long)p.GeslachtId !) && familyIds.Contains((long)p.FamilieId !) && typeIds.Contains((long)p.TypeId !) && PlantenParser.ParseSearchText(p.Fgsv) .Contains(PlantenParser.ParseSearchText(name))) .Select(p => { p.Variant ??= NoVariant; return p; }) .OrderBy(p => p.Fgsv) .ToList()); }
//Get the Species id's (Lily) private List <long> GetSpeciesIds(string species) { return(_context.TfgsvSoort.ToList().Where(s => PlantenParser.ParseSearchText(s.Soortnaam) .Contains(PlantenParser.ParseSearchText(species))) .Select(s => s.Soortid) .ToList()); }
//Get the Genus id's (Lily) private List <long> GetGenusIds(string genus) { return(_context.TfgsvGeslacht.ToList().Where(g => PlantenParser.ParseSearchText(g.Geslachtnaam) .Contains(PlantenParser.ParseSearchText(genus))) .Select(g => g.GeslachtId) .ToList()); }
//Get the family id's (Lily) private List <long> GetFamilyIds(string family) { return(_context.TfgsvFamilie.ToList().Where(f => PlantenParser.ParseSearchText(f.Familienaam) .Contains(PlantenParser.ParseSearchText(family))) .Select(f => f.FamileId) .ToList()); }
//Get the Type Id's (Lily) private List <long> GetTypeIds(string type) { return(_context.TfgsvType.ToList().Where(t => PlantenParser.ParseSearchText(t.Planttypenaam) .Contains(PlantenParser.ParseSearchText(type))) .Select(t => t.Planttypeid) .ToList()); }
//get all unique species names (Davy&Lily&Jim) public List <string> GetUniqueSpeciesNames() { return(_context.TfgsvSoort .ToList() .Select(s => PlantenParser.ParseSearchText(s.Soortnaam)) .Distinct() .OrderBy(soortnaam => soortnaam) .ToList()); }
//get all unique variants (Davy&Lily&Jim) public List <string> GetUniqueVariantNames() { var list = _context.TfgsvVariant .ToList() .Select(v => v.Variantnaam) .Distinct() .OrderBy(variantnaam => PlantenParser.ParseSearchText(variantnaam)) .ToList(); list.Insert(0, NoVariant); return(list); }