Ejemplo n.º 1
0
        public ActionResult Search(bool reset = false)
        {
            //ToDo think about setting sessions, is this the rigth place ?
            //load all names in session

            getAllNames();

            if (reset)
            {
                ResetSearchProvider();
            }

            SearchProvider sp             = GetSearchProvider();
            SubjectManager subjectManager = new SubjectManager();

            //Get all subjects
            var subjects = subjectManager.GetAll <Subject>();

            SearchModel Model = new SearchModel(subjects.ToList().OrderBy(s => s.Name).ToList());

            SearchManager searchManager = new SearchManager();

            var species = searchManager.Search(sp.SearchCriterias);

            if (species != null)
            {
                //convert all subjects to subjectModels
                species = species.OrderBy(p => p.Name);
                species.ToList().ForEach(s => Model.Species.Add(NodeModel.Convert(s)));
            }

            Model.SearchCriterias = sp.SearchCriterias;

            return(View("Search", Model));
        }
Ejemplo n.º 2
0
        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"));;
        }
Ejemplo n.º 3
0
        // GET api/<controller>
        public List <NodeModel> Get()
        {
            List <NodeModel> list = new List <NodeModel>();

            SubjectManager manager = new SubjectManager();
            var            species = manager.GetAll <Species>();

            species.OrderBy(s => s.Name).ToList().ForEach(n => list.Add(NodeModel.Convert(n)));


            return(list);
        }
Ejemplo n.º 4
0
        public ActionResult UpdateSearch()
        {
            List <NodeModel> Model         = new List <NodeModel>();
            SearchProvider   sp            = GetSearchProvider();
            SearchManager    searchManager = new SearchManager();

            var species = searchManager.Search(sp.SearchCriterias);

            if (species != null)
            {
                //convert all subjects to subjectModels
                species = species.OrderBy(p => p.Name);
                species.ToList().ForEach(s => Model.Add(NodeModel.Convert(s)));
            }

            return(PartialView("_searchResult", Model));
        }
Ejemplo n.º 5
0
        public ActionResult Search(string searchValue)
        {
            SearchProvider sp = GetSearchProvider();

            if (searchValue == null)
            {
                sp.DeleteSearchCriterias(SearchProvider.FREETEXT_SEARCH_KEY);
            }
            else
            {
                sp.UpateSearchCriterias(SearchProvider.FREETEXT_SEARCH_KEY, searchValue);
            }

            Debug.WriteLine("SEARCH : " + searchValue);

            List <NodeModel> Model          = new List <NodeModel>();
            SubjectManager   subjectManager = new SubjectManager();

            //Get filtered subjects
            //var species = sp.Search();

            SearchManager searchManager = new SearchManager();

            var species = searchManager.Search(sp.SearchCriterias);

            if (species != null)
            {
                //convert all subjects to subjectModels
                species = species.OrderBy(p => p.Name);
                species.ToList().ForEach(s => Model.Add(NodeModel.Convert(s)));
            }

            //update searchcriterias

            return(PartialView("_searchResult", Model));
        }