public bool RenameFileMetadata(ChangeFileMetadataNameRequest data) { var isUpdated = false; var fileMetadata = _context.UploadedFileInfo.Find(data.Id); var oldName = fileMetadata.Url; var originalDirectory = ConfigurationManager.AppSettings["uploadDestination"]; var newFileLocation = string.Format("{0}\\{1}", originalDirectory, data.NewName); if (fileMetadata != null) { // TO DO - Check if file extension is correct fileMetadata.FileName = data.NewName; fileMetadata.Url = newFileLocation; try { _context.Entry(fileMetadata).State = EntityState.Modified; isUpdated = Save(); RenameFileInFileSystem(oldName, newFileLocation); } catch (Exception e) { // TO DO } } return(isUpdated); }
public bool UpdateFileMetadata([FromBody] ChangeFileMetadataNameRequest data) { var isUpdated = _repository.RenameFileMetadata(data); return(isUpdated); }