예제 #1
0
        public async Task <ActionResult> Update(
            [Bind(Prefix = "Entity.ID")] Guid id,
            [Bind(Prefix = "Entity.RowVersion")] byte[] rowVersion,
            [Bind(Prefix = "Args")] AnnotationEditArgs editArgs)
        {
            if (!ModelState.IsValid)
            {
                return(HttpStatusCodeResults.HttpBadRequest(ModelState));
            }

            var annotation = await Find <Annotation, Guid?>(id, "Entity", false);

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

            if (ModelState.IsValid)
            {
                return(await DbUpdateResult(
                           annotation,
                           rowVersion,
                           editArgs.EndEditAction));
            }
            else
            {
                return(await Edit(annotation, editArgs));
            }
        }
예제 #2
0
        public async Task <ActionResult> SetTerm(
            [Bind(Prefix = "Args")] AnnotationEditArgs editArgs)
        {
            if (!ModelState.IsValid)
            {
                return(HttpStatusCodeResults.HttpBadRequest(ModelState));
            }

            var annotation = Restore <Annotation>("Entity", true);
            var termQuery  = new TermQuery();

            TryUpdateModel(termQuery, "TermQuery");
            ModelState.Clear();

            if (string.IsNullOrWhiteSpace(editArgs.SelectedTermId) == false)
            {
                if (await FaToolDbEntities.Exists <Annotation>(x => x.FK_Protein == annotation.FK_Protein && x.FK_Term == editArgs.SelectedTermId))
                {
                    ModelState.AddModelError("Args.SelectedTermId", "Selected function term already mapped to protein.");
                    return(await SelectTerm(annotation, termQuery, editArgs));
                }
                else
                {
                    annotation.FK_Term = editArgs.SelectedTermId;
                }
            }
            else
            {
                ModelState.AddModelError("Args.SelectedTermId", "A term must be selected.");
                return(await SelectTerm(annotation, termQuery, editArgs));
            }

            return(await Edit(annotation, editArgs));
        }
예제 #3
0
        public async Task <ActionResult> ChangeTerm(
            [Bind(Prefix = "Args")] AnnotationEditArgs editArgs)
        {
            if (!ModelState.IsValid)
            {
                return(HttpStatusCodeResults.HttpBadRequest(ModelState));
            }

            var annotation = Restore <Annotation>("Entity", true);

            return(await ChangeTerm(annotation, new TermQuery(), editArgs));
        }
        public async Task <ActionResult> SearchFunctions(FunctionSearchQuery fsq)
        {
            if (ModelState.IsValid)
            {
                var query = from sp in FaToolDbEntities.GetProteinSearchValues(ProteinSearchOption.ProteinName, fsq.OrganismId)
                            join fp in FaToolDbEntities.GetProteinSearchValues(ProteinSearchOption.Function, fsq.OrganismId) on sp.ProteinID equals fp.ProteinID
                            where sp.Value == fsq.SearchName && fp.OntologyID == fsq.OntologyId
                            select new { id = fp.TermID, name = fp.TermName };

                var results = await query.ToArrayAsync();

                return(Json(results, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(HttpStatusCodeResults.HttpBadRequest(ModelState));
            }
        }
예제 #5
0
        public async Task <ActionResult> Insert(
            [Bind(Prefix = "Args")] AnnotationEditArgs editArgs)
        {
            if (!ModelState.IsValid)
            {
                return(HttpStatusCodeResults.HttpBadRequest(ModelState));
            }

            var annotation = Restore <Annotation>("Entity", false);

            if (ModelState.IsValid)
            {
                return(await DbInsertResult(
                           annotation,
                           editArgs.EndEditAction));
            }
            else
            {
                return(await Edit(annotation, editArgs));
            }
        }
예제 #6
0
        public async Task <ActionResult> SelectTerm(
            [Bind(Prefix = "Args")] AnnotationEditArgs editArgs)
        {
            if (!ModelState.IsValid)
            {
                return(HttpStatusCodeResults.HttpBadRequest(ModelState));
            }

            var termQuery = new TermQuery();

            if (TryUpdateModel(termQuery, "TermQuery"))
            {
                var annotation = Restore <Annotation>("Entity", true);
                return(await SelectTerm(annotation, termQuery, editArgs));
            }
            else
            {
                var annotation = Restore <Annotation>("Entity", true);
                return(await ChangeTerm(annotation, termQuery, editArgs));
            }
        }