Completata gestione allegati e riepilogo commessa

This commit is contained in:
2025-09-01 17:38:16 +02:00
parent 588dbe308a
commit 8be3fa9f9e
17 changed files with 341 additions and 60 deletions

View File

@@ -13,6 +13,7 @@
@inject IIntegryApiService IntegryApiService
@inject IMessenger Messenger
@inject IDialogService Dialog
@inject IAttachedService AttachedService
<MudDialog Class="customDialog-form">
<DialogContent>
@@ -142,7 +143,7 @@
{
foreach (var file in ActivityFileList)
{
<MudChip T="string" Color="Color.Default">
<MudChip T="string" OnClick="() => OpenAttached(file.Id, file.FileName)" Color="Color.Default">
@file.FileName
</MudChip>
}
@@ -315,7 +316,7 @@
await ManageData.InsertOrUpdate(newActivity);
await SaveAttached(newActivity.ActivityId);
await SaveAttached(newActivity.ActivityId!);
SuccessAnimation = true;
StateHasChanged();
@@ -353,7 +354,7 @@
{
if (attached.FileContent is not null && attached.Type != AttachedDTO.TypeAttached.Position)
{
await IntegryApiService.UploadFile(activityId, attached.FileContent, attached.Name);
await IntegryApiService.UploadFile(activityId, attached.FileBytes, attached.Name);
}
}
}
@@ -541,12 +542,26 @@
StateHasChanged();
}
private async Task OpenAttached(string idAttached, string fileName)
{
try
{
var bytes = await IntegryApiService.DownloadFile(ActivityModel.ActivityId!, fileName);
await AttachedService.OpenFile(bytes, fileName);
}
catch (Exception ex)
{
Snackbar.Clear();
Snackbar.Add("Impossibile aprire il file", Severity.Error);
Console.WriteLine($"Errore durante l'apertura del file: {ex.Message}");
}
}
private async Task OpenAttached(AttachedDTO attached)
{
if (attached is { FileContent: not null, MimeType: not null })
{
var fileViewerUrl = $"data:{attached.MimeType};base64,{Convert.ToBase64String(attached.FileContent)}";
await ModalHelpers.OpenViewAttach(Dialog, fileViewerUrl);
await AttachedService.OpenFile(attached.FileContent!, attached.Name);
}
else
{