Beispiel #1
0
        public UsersSeeder(DataContainer dataContainer, string configDir)
        {
            this.dataContainer   = dataContainer;
            this.configDir       = configDir;
            configSeedAvatarsDir = Path.Combine(configDir, SeederPathsNames.InitDir, SeederPathsNames.AvatarsDir);
            PathService pathService = new PathService(configDir);

            uploadImagesDir = pathService.GetPath(PathNames.UploadImagesDirName);
        }
Beispiel #2
0
 public IActionResult RenameFile([FromBody] RenameFileModel model, [FromServices] PathService pathService)
 {
     try
     {
         var file = FilesRepo.Files[model.FileName];
         if (file == null)
         {
             throw new Exception("file not found");
         }
         var newPath = Path.Combine(pathService.GetPath(), model.NewName) +
                       Path.GetExtension(model.FileName);
         System.IO.File.Move(file.FilePath, newPath);
         FilesRepo.Files.Remove(file.FilePath, out file);
         file.FilePath            = newPath;
         FilesRepo.Files[newPath] = file;
         return(Ok(new { path = newPath }));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(BadRequest(e.Message));
     }
 }