Пример #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);
        }
Пример #2
0
        public async Task <IUser> CreateNewUser(string userKeyCloakId)
        {
            IUser model = new User {
                KeycloakId = userKeyCloakId
            };

            model = await userController.InsertAsync(model);

            await userController.SaveChangesAsync();

            return(model);
        }
Пример #3
0
        public static async Task <IImage> ImageUploadAsync(IData data)
        {
            try
            {
                data = GetBase64OutOfXML(data);
                var      bytes   = data.Base64.Base64ToByte();
                IProject project = await projectController.GetByIdAsync(data.ProjectId);

                Image image = new Image();
                image.Width  = data.Width;
                image.Height = data.Height;

                //Queries whether the directory (for images) of the respective project exists and creates it if not.
                string dir_path = $"./Ressources/Images/{project.Id}_{project.Name}";
                if (!System.IO.Directory.Exists(dir_path))
                {
                    System.IO.Directory.CreateDirectory(dir_path);
                }

                //Queries whether the image exists
                //  -if so, it will only be updated
                //  -if no, a database entry is made with the respective path
                string img_path = $"./Ressources/Images/{project.Id}_{project.Name}/{data.Name}";
                if (!System.IO.File.Exists(img_path))
                {
                    image.ImagePath = img_path;
                    image.ProjectId = data.ProjectId;
                }

                //the image is saved
                await System.IO.File.WriteAllBytesAsync(img_path, bytes);

                await imageController.InsertAsync(image);

                await imageController.SaveChangesAsync();

                return(image);
            }
            catch (Exception er)
            {
                Console.WriteLine(er.ToString());
                return(null);
            }
        }
Пример #4
0
        public async Task AddAIConfigToProjectAsync(int projectId, IAIModelConfig model)
        {
            await project_AiModelConfigController.InsertAsync(new Project_AIModelConfig { AIConfigKey = model.Id, ProjectKey = projectId });

            await project_AiModelConfigController.SaveChangesAsync();
        }
Пример #5
0
        public async Task AddUserToProject(int projectId, IUser model)
        {
            await project_userController.InsertAsync(new Project_User { UserIdKey = model.Id, ProjectKey = projectId });

            await project_userController.SaveChangesAsync();
        }