Exemple #1
0
        public async Task <ActionResult> Get(Guid id, AnnotationNavId navId = AnnotationNavId.Term)
        {
            var annotation = await FaToolDbEntities.Find <Annotation>(id);

            if (annotation == null)
            {
                return(HttpNotFound("Entity not found in database."));
            }

            await FaToolDbEntities.LoadReference(annotation, x => x.Term, "Ontology");

            ViewBag.Title = string.Format("Annotation '{0}' - [{1}]", annotation.Term.Name, navId.ToString());

            var model = new EntityView <Annotation, AnnotationNavId>();

            model.NavTabs   = Url.CreateNavTabs <Guid?, AnnotationNavId>(id);
            model.ActiveTab = model.NavTabs.ToggleActive(navId);

            model.Properties = new AnnotationRecordView(annotation);
            model.Properties.Actions.Add(Url.EntityActionLink("Edit", "Edit", id, User.IsAdminRole() == false));
            model.Properties.Actions.Add(Url.EntityGetActionLink("Back to Protein", "Proteins", annotation.FK_Protein, ProteinNavId.Functions));

            switch (navId)
            {
            case AnnotationNavId.Term:
                await FaToolDbEntities.LoadReference(annotation, x => x.Term, "Ontology");

                model.TabContent = new TermRecordView(annotation.Term);
                break;

            case AnnotationNavId.References:
                await FaToolDbEntities.LoadCollection(annotation, x => x.References);

                model.TabContent = new ParamList(annotation.Params);
                break;

            case AnnotationNavId.Description:
                await FaToolDbEntities.LoadCollection(annotation, x => x.Params, "Term.Ontology", "Unit.Ontology");

                model.TabContent = new PubReferenceList(annotation.References);
                break;

            default:
                break;
            }

            return(View("EntityDefault", model));
        }
Exemple #2
0
        public async Task <ActionResult> Get(Guid id, ProteinNavId navId = ProteinNavId.Functions)
        {
            var protein = await FaToolDbEntities.Find <Protein>(id);

            if (protein == null)
            {
                return(HttpNotFound("Protein not found in database."));
            }

            ViewBag.Title = string.Format("Protein '{0}' - [{1}]", protein.Name, navId.ToString());

            var model = new EntityView <Protein, ProteinNavId>();

            model.NavTabs   = Url.CreateNavTabs <Guid?, ProteinNavId>(id);
            model.ActiveTab = model.NavTabs.ToggleActive(navId);

            model.Properties = new ProteinRecordView(protein);

            switch (navId)
            {
            case ProteinNavId.Functions:
                await FaToolDbEntities.LoadCollection(protein, x => x.Annotations, "Term.Ontology");

                var annotationList = new AnnotationList(protein.Annotations);
                annotationList.AddRowAction(x => Url.EntityGetActionLink("Show", "Annotations", x.ID));
                annotationList.Actions.Add(Url.ActionLink("Add", "Create", "Annotations", new { proteinId = id }, User.IsAdminRole() == false));
                model.TabContent = annotationList;
                break;

            case ProteinNavId.Synonyms:
                await FaToolDbEntities.LoadCollection(protein, x => x.Synonyms, "SynonymType.Ontology");

                model.TabContent = new SynonymList(protein.Synonyms);
                break;

            case ProteinNavId.Description:
                await FaToolDbEntities.LoadCollection(protein, x => x.Params, "Term.Ontology", "Unit.Ontology");

                model.TabContent = new ParamList(protein.Params);
                break;

            case ProteinNavId.References:
                await FaToolDbEntities.LoadCollection(protein, x => x.References);

                model.TabContent = new PubReferenceList(protein.References);
                break;

            case ProteinNavId.GeneModels:
                await FaToolDbEntities.LoadCollection(protein, x => x.GeneModels, "GeneModelSource.Organism.Ontology");

                model.TabContent = new GeneModelList(protein.GeneModels);
                break;

            case ProteinNavId.Homologs:
                await FaToolDbEntities.LoadCollection(protein, x => x.ProteinHomologyGroups, "Group");

                model.TabContent = new ProteinHomologyGroupList(protein.ProteinHomologyGroups);
                break;

            default:
                throw new InvalidOperationException("Invalid nav id.");
            }

            return(View("EntityDefault", model));
        }