public ActionResult Details(long id, string type) { SubjectManager sm = new SubjectManager(); Subject s = sm.Get(id); //load by loading the page and store it in a session!!!! switch (type) { case "Plant": { Plant plant = sm.GetAll <Plant>().Where(p => p.Id.Equals(id)).FirstOrDefault(); PlantModel Model = PlantModel.Convert(plant); //load interactions Model.Interactions = SubjectModel.ConverInteractionModels(sm.GetAllDependingInteractions(plant, true).ToList()); return(View("PlantDetails", Model)); } case "Animal": { Animal animal = sm.GetAll <Animal>().Where(a => a.Id.Equals(id)).FirstOrDefault(); AnimalModel Model = AnimalModel.Convert(animal); Model.Interactions = SubjectModel.ConverInteractionModels(sm.GetAllDependingInteractions(animal, true).ToList()); return(View("AnimalDetails", Model)); } case "Taxon": { Taxon taxon = sm.GetAll <Taxon>().Where(a => a.Id.Equals(id)).FirstOrDefault(); NodeModel Model = NodeModel.Convert(taxon); return(View("TaxonDetails", Model)); } case "Effect": { Effect effect = sm.GetAll <Effect>().Where(e => e.Id.Equals(id)).FirstOrDefault(); return(View("EffectDetails")); } case "Unknow": { SubjectModel Model = SubjectModel.Convert(s); return(View("SubjectDetails", Model)); } default: { break; } } return(RedirectToAction("Search", "Search"));; }
// GET api/<controller>/5 public AnimalModel Get(int id) { SubjectManager manager = new SubjectManager(); var animal = manager.GetAll <Animal>().Where(p => p.Id.Equals(id)).FirstOrDefault(); AnimalModel model = AnimalModel.Convert(animal); model.Interactions = AnimalModel.ConverInteractionModels(manager.GetAllDependingInteractions(animal, true).ToList()); return(model); }
// GET api/<controller>/5 public PlantModel Get(int id) { SubjectManager manager = new SubjectManager(); var plant = manager.GetAll <Plant>().Where(p => p.Id.Equals(id)).FirstOrDefault(); PlantModel model = PlantModel.Convert(plant); model.Interactions = PlantModel.ConverInteractionModels(manager.GetAllDependingInteractions(plant, true).ToList()); return(model); }