コード例 #1
0
 public async Task <List <BodyPartReference> > Search([FromQuery(Name = "")] BodyPartClassifications criteria, [FromQuery(Name = "")] OffsetLimit offsetLimit)
 {
     if (criteria == null)
     {
         criteria = new BodyPartClassifications();
     }
     return(await _dao.Search(criteria, offsetLimit.Offset, offsetLimit.Limit));
 }
コード例 #2
0
        public async Task <List <StructureReference> > Search([FromQuery(Name = "")] StructureClassifications criteria, [FromQuery(Name = "")] OffsetLimit offsetLimit)
        {
            if (criteria == null)
            {
                criteria = new StructureClassifications();
            }

            var image = await _dao.Search(criteria, offsetLimit.Offset, offsetLimit.Limit);

            return(image);
        }
コード例 #3
0
        public async Task <List <FullBodyReference> > Search([FromQuery(Name = "")] FullBodyClassifications criteria, [FromQuery(Name = "")] OffsetLimit offsetLimit)
        {
            if (criteria == null)
            {
                criteria = new FullBodyClassifications();
            }
            if (offsetLimit == null)
            {
                offsetLimit = new OffsetLimit();
            }

            return(await _dao.Search(criteria, offsetLimit.Offset, offsetLimit.Limit));
        }
コード例 #4
0
        public async Task <BatchImages> GetBatchImages(string id)
        {
            var results = new BatchImages();

            var currentUser = GetCurrentUser();

            results.Batch = await _batchDAO.Get(id);

            if (results.Batch == null)
            {
                return(results);
            }

            if (!currentUser.IsAdmin && currentUser.Email != results.Batch.User)
            {
                throw new Exception("Unauthorized");
            }

            if (results.Batch.Type == ReferenceType.Animal)
            {
                var queryable  = new AnimalsQueryable();
                var animalsDAO = new ReferenceDAO <AnimalReference, AnimalClassifications>(ReferenceType.Animal, queryable);
                var images     = await animalsDAO.Search(new AnimalClassifications()
                {
                    BatchId = id
                });

                results.Images = images.ToList <object>();
            }
            else if (results.Batch.Type == ReferenceType.BodyPart)
            {
                var queryable    = new BodyPartsQueryable();
                var bodyPartsDAO = new ReferenceDAO <BodyPartReference, BodyPartClassifications>(ReferenceType.BodyPart, queryable);
                var images       = await bodyPartsDAO.Search(new BodyPartClassifications { BatchId = id });

                results.Images = images.ToList <object>();
            }
            else if (results.Batch.Type == ReferenceType.FullBody)
            {
                var queryable     = new FullBodiesQueryable();
                var fullBodiesDAO = new ReferenceDAO <FullBodyReference, FullBodyClassifications>(ReferenceType.FullBody, queryable);
                var images        = await fullBodiesDAO.Search(new FullBodyClassifications { BatchId = id });

                results.Images = images.ToList <object>();
            }
            else if (results.Batch.Type == ReferenceType.Vegetation)
            {
                var queryable     = new VegetationQueryable();
                var vegetationDAO = new ReferenceDAO <VegetationReference, VegetationClassifications>(ReferenceType.Vegetation, queryable);
                var images        = await vegetationDAO.Search(new VegetationClassifications { BatchId = id });

                results.Images = images.ToList <object>();
            }
            else if (results.Batch.Type == ReferenceType.Structure)
            {
                var queryable     = new StructuresQueryable();
                var structuresDAO = new ReferenceDAO <StructureReference, StructureClassifications>(ReferenceType.Structure, queryable);
                var images        = await structuresDAO.Search(new StructureClassifications { BatchId = id });

                results.Images = images.ToList <object>();
            }

            return(results);
        }