@@ -170,10 +170,10 @@ public IActionResult SetAttachment(DlsSubApplication dlsSubApplication, RequestA
170170 MultiPageFormDataFeature . AddCustomWebForm ( "RequestSupportTicketCWF" ) ,
171171 TempData
172172 ) . GetAwaiter ( ) . GetResult ( ) ; ;
173-
173+ requestAttachmentmodel . RequestAttachment = data . RequestAttachment ;
174174 if ( requestAttachmentmodel . ImageFiles == null )
175175 {
176- requestAttachmentmodel . RequestAttachment = data . RequestAttachment ;
176+ // requestAttachmentmodel.RequestAttachment = data.RequestAttachment;
177177 ModelState . AddModelError ( "ImageFiles" , "Please select at least one image" ) ;
178178 return View ( "RequestAttachment" , requestAttachmentmodel ) ;
179179 }
@@ -184,13 +184,13 @@ public IActionResult SetAttachment(DlsSubApplication dlsSubApplication, RequestA
184184 ( bool ? fileExtension , bool ? fileSize ) = validateUploadedImages ( requestAttachmentmodel ) ;
185185 if ( fileExtension == true )
186186 {
187- requestAttachmentmodel . RequestAttachment = data . RequestAttachment ;
187+ // requestAttachmentmodel.RequestAttachment = data.RequestAttachment;
188188 ModelState . AddModelError ( "FileExtensionError" , "File must be in valid image formats jpg, jpeg, png, bmp or mp4 video format" ) ;
189189 return View ( "RequestAttachment" , requestAttachmentmodel ) ;
190190 }
191191 if ( fileSize == true )
192192 {
193- requestAttachmentmodel . RequestAttachment = data . RequestAttachment ;
193+ // requestAttachmentmodel.RequestAttachment = data.RequestAttachment;
194194 ModelState . AddModelError ( "FileSizeError" , "Maximum allowed file size is 20MB" ) ;
195195 return View ( "RequestAttachment" , requestAttachmentmodel ) ;
196196 }
@@ -202,7 +202,8 @@ public IActionResult SetAttachment(DlsSubApplication dlsSubApplication, RequestA
202202 {
203203 OriginalFileName = item . FileName ,
204204 FileName = fileName ,
205- FullFileName = uploadDir + fileName
205+ FullFileName = uploadDir + fileName ,
206+ SizeMb = Convert . ToDouble ( item . Length . ToSize ( FileSizeCalc . SizeUnits . MB ) )
206207 } ;
207208 RequestAttachmentList . Add ( RequestAttachment ) ;
208209 }
@@ -370,6 +371,13 @@ private string UploadFile(IFormFile file)
370371 private ( bool , bool ) validateUploadedImages ( RequestAttachmentViewModel requestAttachmentmodel )
371372 {
372373 var totalFileSize = 0.00 ;
374+ if ( requestAttachmentmodel . RequestAttachment != null )
375+ {
376+ foreach ( var item in requestAttachmentmodel . RequestAttachment )
377+ {
378+ totalFileSize = totalFileSize + item . SizeMb ?? 0 ;
379+ }
380+ }
373381 foreach ( var item in requestAttachmentmodel . ImageFiles )
374382 {
375383 var extension = Path . GetExtension ( item . FileName ) ;
@@ -380,10 +388,11 @@ private string UploadFile(IFormFile file)
380388 }
381389 var fileSize = Convert . ToDouble ( item . Length . ToSize ( FileSizeCalc . SizeUnits . MB ) ) ;
382390 totalFileSize = totalFileSize + fileSize ;
383- if ( fileSize > requestAttachmentmodel . SizeLimit || totalFileSize > requestAttachmentmodel . SizeLimit )
384- {
385- requestAttachmentmodel . FileSizeFlag = true ;
386- }
391+
392+ }
393+ if ( totalFileSize > requestAttachmentmodel . SizeLimit )
394+ {
395+ requestAttachmentmodel . FileSizeFlag = true ;
387396 }
388397 return ( requestAttachmentmodel . FileExtensionFlag ?? false , requestAttachmentmodel . FileSizeFlag ?? false ) ;
389398 }
0 commit comments