Exemplo n.º 1
0
        public IActionResult EditFile(int fileId, IFormFile file)
        {
            StoredFileDTO fileById       = _fileLogic.GetFileById(fileId);
            bool          hasNameChanged = fileById.FileName.Equals(file.FileName);
            string        newFileName    = _fileLogic.UpdateFile(new StoredFileDTO
            {
                Id         = fileId,
                FileName   = file.FileName,
                FileSize   = _shareControllerHelper.FormatSize(file.Length),
                UploadDate = DateTime.Now,
                UserId     = _accountLogic.GetCurentUserById()
            }, !hasNameChanged);

            _fileLogic.ReplaceFileOnDisk(file, _uploads, !hasNameChanged, newFileName);
            return(RedirectToAction("Files"));
        }