public void AddImageAnalysis(Domain.ImageFile imageFile, AzureCvModels.ImageAnalysis imageAnalysis)
        {
            ImageAnalysis dbImageAnalysis    = Mapper.Map <ImageAnalysis>(imageAnalysis);
            ImageAnalysis addedImageAnalysis = _computerVisionContext.ImageAnalysis.Add(dbImageAnalysis).Entity;

            _computerVisionContext.SaveChanges();
            ImageFile dbImageFile = _computerVisionContext.ImageFile.SingleOrDefault(x => x.HashString == imageFile.HashString);

            if (dbImageFile != null)
            {
                dbImageFile.AnylysisId = addedImageAnalysis.Id;
            }
            _computerVisionContext.SaveChanges();
        }
        public AzureCvModels.ImageAnalysis GetImageAnalysis(Domain.ImageFile imageFile)
        {
            ImageFile dbImageFile = _computerVisionContext.ImageFile.SingleOrDefault(x => x.HashString == imageFile.HashString);

            if (dbImageFile != null)
            {
                ImageAnalysis dbImageAnalysis             = GetImageAnalysis(dbImageFile);
                AzureCvModels.ImageAnalysis imageAnalysis = null;
                if (dbImageAnalysis != null)
                {
                    imageAnalysis = Mapper.Map <AzureCvModels.ImageAnalysis>(dbImageAnalysis);
                }
                return(imageAnalysis);
            }

            return(null);
        }
        private ImageAnalysis GetImageAnalysis(ImageFile dbImageFile)
        {
            ImageAnalysis dbImageAnalysis = _computerVisionContext.ImageAnalysis
                                            .Include(x => x.Adult)
                                            .Include(x => x.Categories)
                                            .ThenInclude(y => y.Detail)
                                            .ThenInclude(y => y.Celebrities)
                                            .ThenInclude(x => x.FaceRectangle)
                                            .Include(x => x.Categories)
                                            .ThenInclude(y => y.Detail)
                                            .ThenInclude(y => y.Landmarks)
                                            .Include(x => x.Color)
                                            .Include(x => x.Description)
                                            .ThenInclude(x => x.Captions)
                                            .Include(x => x.ImageType)
                                            .Include(x => x.Metadata)
                                            .Include(x => x.Tags)
                                            .SingleOrDefault(x => x.Id == dbImageFile.AnylysisId)
            ;

            return(dbImageAnalysis);
        }