コード例 #1
0
ファイル: SpeciesController.cs プロジェクト: DavidBlaa/mct
        // GET api/<controller>/5
        public SubjectModel Get(int id)
        {
            SubjectManager manager = new SubjectManager();
            var            subject = manager.Get(id);

            return(SubjectModel.Convert(subject));
        }
コード例 #2
0
ファイル: SubjectController.cs プロジェクト: DavidBlaa/mct
        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"));;
        }