Beispiel #1
0
        public async Task <IProject> CreateAsync(IProject project, IEnumerable <int> aiConfigs, IEnumerable <IData> images, string keycloakUser)
        {
            var user = await userManagementController.GetUserId(keycloakUser);

            IProject result = await projectController.InsertAsync(project);

            await projectController.SaveChangesAsync();

            foreach (var item in aiConfigs)
            {
                await projectAIModelConfigController.InsertAsync(new Project_AIModelConfig { AIConfigKey = item, ProjectKey = result.Id });

                await projectAIModelConfigController.SaveChangesAsync();
            }
            foreach (var image in images)
            {
                image.ProjectId = result.Id;
                await Base64Controller.ImageUploadAsync(image);
            }
            await projectUserController.InsertAsync(new Project_User { ProjectKey = result.Id, UserIdKey = user.Id });

            await projectUserController.SaveChangesAsync();

            return(result);
        }
Beispiel #2
0
        public async Task <IProject> UpdateProjectAsync(IProject project)
        {
            IProject oldProject = await projectController.GetByIdAsync(project.Id);

            IProject oldProjectWithLabel = await GetProjectWithLabelAsync(project.Id);

            project.LabeledPath = await Base64Controller.CocoUploadAsync(new Data
            {
                ProjectId = project.Id, Name = project.Name, Format = "", Base64 = project.LabeledPath,
                Height    = 0, Width = 0
            });

            if (oldProject.LabeledPath != project.LabeledPath)
            {
                if (File.Exists(oldProject.LabeledPath))
                {
                    File.Delete(oldProject.LabeledPath);
                }
            }
            IProject respondModel = await projectController.UpdateAsync(project);

            await projectController.SaveChangesAsync();

            return(respondModel);
        }
Beispiel #3
0
        public async Task <IEnumerable <IData> > GetImagesForProject(int projectId)
        {
            List <IData> projectImages = new List <IData>();

            IImage[] images = (await imageController.GetAllWhereAsync(i => i.ProjectId == projectId)).ToArray();
            foreach (var image in images)
            {
                projectImages.Add(Base64Controller.GetPictureAsync(image));
            }
            return(projectImages);
        }
Beispiel #4
0
 public Task DeleteAsync(int id)
 {
     return(Base64Controller.RemoveImageAsync(id));
 }
Beispiel #5
0
 public Task UploadImageAsync(IData data)
 {
     return(Base64Controller.ImageUploadAsync(data));
 }
Beispiel #6
0
        public async Task <IData> GetFirstImageOfProject(int projectId)
        {
            IImage image = (await imageController.GetAllWhereAsync(e => e.ProjectId == projectId)).FirstOrDefault();

            return(Base64Controller.GetPictureAsync(image));
        }
Beispiel #7
0
 public Task <IData> GetImageAsync(int id)
 {
     return(Base64Controller.GetPictureByIdAsync(id));
 }