//=INDEX=============================================================== // GET: Organism public async Task <IActionResult> Index() { OrganismClassification OrganismC = new OrganismClassification(); await TryUpdateModelAsync(OrganismC); ChosenTaxons viewModel = await ChosenTaxonsFiller.Fill(_context, OrganismC); return(View(viewModel)); }
// GET: Learning/AddSource/5 public async Task <IActionResult> SourceIndex(int learningSetID) { OrganismClassification OrganismC = new OrganismClassification(); await TryUpdateModelAsync(OrganismC); ChosenTaxons viewModel = await ChosenTaxonsFiller.Fill(_context, OrganismC); ViewBag.LearningSetID = learningSetID; return(View(viewModel)); }
private async Task <string> GetClassification(OrganismData model, OrganismDbContext _context) { ChosenTaxons cht = await ChosenTaxonsFiller.Fill(_context, model); return(cht.ChosenKingdom.Name + ", " + cht.ChosenPhylum.Name + ", " + cht.ChosenClass.Name + ", " + cht.ChosenOrder.Name + ", " + cht.ChosenFamily.Name + ", " + cht.ChosenGenus.Name); }
public static async Task <OrganismData> Fill(OrganismDbContext _context, OrganismData viewModel) { ChosenTaxons taxons = await ChosenTaxonsFiller.Fill(_context, viewModel); if (viewModel.KingdomID != null) { viewModel.Name = taxons.ChosenKingdom.Name; } if (viewModel.PhylumID != null) { viewModel.Name = taxons.ChosenPhylum.Name; } if (viewModel.ClassID != null) { viewModel.Name = taxons.ChosenClass.Name; } if (viewModel.OrderID != null) { viewModel.Name = taxons.ChosenOrder.Name; } if (viewModel.FamilyID != null) { viewModel.Name = taxons.ChosenFamily.Name; } if (viewModel.GenusID != null) { viewModel.Name = taxons.ChosenGenus.Name; } if (viewModel.SpeciesID != null) { viewModel.Name = taxons.ChosenSpecies.Name; viewModel.Description = taxons.ChosenSpecies.Description; viewModel.Class = taxons.ChosenSpecies.Class; viewModel.Classification = taxons.ChosenSpecies.Classification; viewModel.Size = taxons.ChosenSpecies.Size; viewModel.Use = taxons.ChosenSpecies.Use; viewModel.OccurenceCR = taxons.ChosenSpecies.OccurenceCR; viewModel.Protection = taxons.ChosenSpecies.Protection; viewModel.EcoFunction = taxons.ChosenSpecies.EcoFunction; viewModel.Ecosystems = taxons.ChosenSpecies.Ecosystems.Split(", ") .Select(x => (EcosystemEnum)Enum.Parse(typeof(EcosystemEnum), x)).ToArray(); viewModel.OccurencesWorld = taxons.ChosenSpecies.OccurencesWorld.Split(", ") .Select(x => (OccurenceWorldEnum)Enum.Parse(typeof(OccurenceWorldEnum), x)).ToArray(); viewModel.Imgs = taxons.ChosenSpecies.Imgs; } return(viewModel); }
public static async Task <ChosenTaxons> Fill(OrganismDbContext _context, OrganismClassification OIDs) { ChosenTaxons viewModel = new ChosenTaxons { Kingdoms = await _context.Kingdoms .Include(i => i.Phylums) .ThenInclude(i => i.Classes) .ThenInclude(i => i.Orders) .ThenInclude(i => i.Families) .ThenInclude(i => i.Genusses) .ThenInclude(i => i.Species) .OrderBy(i => i.Name) .ToListAsync() }; if (OIDs.KingdomID != null) { viewModel.ChosenKingdom = viewModel.Kingdoms .Single(x => x.KingdomTID == OIDs.KingdomID); } if (OIDs.PhylumID != null) { viewModel.ChosenPhylum = viewModel.ChosenKingdom.Phylums .Single(x => x.PhylumTID == OIDs.PhylumID); } if (OIDs.ClassID != null) { viewModel.ChosenClass = viewModel.ChosenPhylum.Classes .Single(x => x.ClassTID == OIDs.ClassID); } if (OIDs.OrderID != null) { viewModel.ChosenOrder = viewModel.ChosenClass.Orders .Single(x => x.OrderTID == OIDs.OrderID); } if (OIDs.FamilyID != null) { viewModel.ChosenFamily = viewModel.ChosenOrder.Families .Single(x => x.FamilyTID == OIDs.FamilyID); } if (OIDs.GenusID != null) { viewModel.ChosenGenus = viewModel.ChosenFamily.Genusses .Single(x => x.GenusTID == OIDs.GenusID); } if (OIDs.SpeciesID != null) { viewModel.ChosenSpecies = viewModel.ChosenGenus.Species .Single(x => x.SpeciesTID == OIDs.SpeciesID); await _context.Entry(viewModel.ChosenSpecies) .Collection(x => x.Imgs).LoadAsync(); } return(viewModel); }