From 9a1232bc1fd78919e4984333d7a5707406dd198f Mon Sep 17 00:00:00 2001 From: AnjuJose011 <154979799+AnjuJose011@users.noreply.github.com> Date: Tue, 19 Aug 2025 10:12:22 +0100 Subject: [PATCH] Defect/Td-5836 --- LearningHub.Nhs.WebUI/Controllers/ContributeController.cs | 3 ++- LearningHub.Nhs.WebUI/Interfaces/IContributeService.cs | 3 ++- LearningHub.Nhs.WebUI/Services/ContributeService.cs | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/LearningHub.Nhs.WebUI/Controllers/ContributeController.cs b/LearningHub.Nhs.WebUI/Controllers/ContributeController.cs index fc3b7f76a..d1feb59eb 100644 --- a/LearningHub.Nhs.WebUI/Controllers/ContributeController.cs +++ b/LearningHub.Nhs.WebUI/Controllers/ContributeController.cs @@ -197,8 +197,9 @@ public async Task UploadArticleFile(IFormCollection inputForm) var file = inputForm.Files[0]; int.TryParse(inputForm["resourceVersionId"], out int resourceVersionId); int.TryParse(inputForm["changeingFileId"], out int existingFileId); + int.TryParse(inputForm["fileSize"], out int fileSize); var currentUserId = this.User.Identity.GetCurrentUserId(); - return await this.contributeService.ProcessArticleFileAsync(resourceVersionId, file, existingFileId, currentUserId); + return await this.contributeService.ProcessArticleFileAsync(resourceVersionId, file, fileSize, existingFileId, currentUserId); } /// diff --git a/LearningHub.Nhs.WebUI/Interfaces/IContributeService.cs b/LearningHub.Nhs.WebUI/Interfaces/IContributeService.cs index 1f7f4154e..2c982adf1 100644 --- a/LearningHub.Nhs.WebUI/Interfaces/IContributeService.cs +++ b/LearningHub.Nhs.WebUI/Interfaces/IContributeService.cs @@ -87,10 +87,11 @@ public interface IContributeService /// /// Resource version id. /// File. + /// fileSize. /// Changing file id. /// Current user id. /// A representing the result of the asynchronous operation. - Task ProcessArticleFileAsync(int resourceVersionId, IFormFile file, int changeingFileId, int currentUserId); + Task ProcessArticleFileAsync(int resourceVersionId, IFormFile file, int fileSize,int changeingFileId, int currentUserId); /// /// The ProcessResourceAttachedFileAsync. diff --git a/LearningHub.Nhs.WebUI/Services/ContributeService.cs b/LearningHub.Nhs.WebUI/Services/ContributeService.cs index 68a2b4cf6..a78d3eb7d 100644 --- a/LearningHub.Nhs.WebUI/Services/ContributeService.cs +++ b/LearningHub.Nhs.WebUI/Services/ContributeService.cs @@ -382,10 +382,11 @@ public async Task GetFileChunkDetail(int fileChunkDeta /// /// The resourceVersionId. /// The file. + /// The fileSize. /// The existingFileId. /// The currentUserId. /// The . - public async Task ProcessArticleFileAsync(int resourceVersionId, IFormFile file, int existingFileId, int currentUserId) + public async Task ProcessArticleFileAsync(int resourceVersionId, IFormFile file, int fileSize, int existingFileId, int currentUserId) { var filelocation = string.Empty; string extension = Path.GetExtension(file.FileName).Replace(".", string.Empty); @@ -415,7 +416,7 @@ public async Task ProcessArticleFileAsync(int resourceVersionI FileTypeId = fileType == null ? 0 : fileType.Id, FileName = file.FileName, FilePath = filelocation, - FileSize = (int)(file.Length / 1000), + FileSize = (int)(fileSize / 1000), ReplacedFileId = existingFileId, }); @@ -425,7 +426,7 @@ public async Task ProcessArticleFileAsync(int resourceVersionI ResourceVersionId = resourceVersionId, FileName = file.FileName, FileTypeId = fileType == null ? 0 : fileType.Id, - FileSizeKb = (int)(file.Length / 1000), + FileSizeKb = (int)(fileSize / 1000), Invalid = false, }; }