@using SteUp.Shared.Components.Layout.Overlay @using SteUp.Shared.Components.SingleElements.MessageBox @using SteUp.Shared.Core.Dto @using SteUp.Shared.Core.Entities @using SteUp.Shared.Core.Enum @using SteUp.Shared.Core.Interface.IntegryApi @using SteUp.Shared.Core.Interface.LocalDb @using SteUp.Shared.Core.Interface.System @inject IIspezioniService IspezioniService @inject IIntegrySteupService IntegrySteupService @inject IDialogService Dialog @inject IFileManager FileManager
@Scheda.ActivityTypeId
@Scheda.ImageNames.Count() @Scheda.Articoli.Count
@if (Ispezione.Stato != StatusEnum.Completata) { if (NetworkService.IsNetworkAvailable()) { } else { Modifica Cancella } } else { Visualizza Esporta immagini }
@code{ [Parameter] public Ispezione Ispezione { get; set; } = new(); [Parameter] public required Scheda Scheda { get; set; } [Parameter] public EventCallback OnSchedaModified { get; set; } [Parameter] public EventCallback OnSchedaDeleted { get; set; } private bool VisibleOverlay { get; set; } private ConfirmMessageBox _messageBox = null!; private async Task UpdateScheda() { var modal = await Dialog.OpenFormScheda(Ispezione.CodMdep, Ispezione.Data, false, Scheda); if (modal is { Canceled: false, Data: Scheda scheda }) await OnSchedaModified.InvokeAsync(scheda); } private async Task DeleteScheda() { var result = await _messageBox.ShowAsync(); if (result is true) { VisibleOverlay = true; StateHasChanged(); if (Scheda.ActivityId != null) await IntegrySteupService.DeleteScheda(Scheda.ActivityId); if (Scheda.ImageNames != null) { foreach (var fileName in Scheda.ImageNames) { FileManager.RemoveInspectionFile(Ispezione, fileName); } } var deleteScheda = await IspezioniService.DeleteSchedaAsync(Scheda.Id); if (deleteScheda) await OnSchedaDeleted.InvokeAsync(Scheda); VisibleOverlay = false; StateHasChanged(); } } private void ViewScheda() => _ = Dialog.OpenFormScheda(Ispezione.CodMdep, Ispezione.Data, false, Scheda, true); private async Task ExportScheda() { VisibleOverlay = true; StateHasChanged(); var apiResponse = await IntegrySteupService.SaveScheda( new SaveRequestDto { LocalIdScheda = Scheda.Id, ActivityTypeId = Scheda.ActivityTypeId, CodJfas = Scheda.CodJfas, CodMdep = Ispezione.CodMdep, DataCreazione = Ispezione.Data, Note = Scheda.Note, PersonaRif = Scheda.Responsabile, Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode), Scandeza = (ScadenzaEnum)Scheda.Scadenza, ParentActivityId = Scheda.Ispezione?.ActivityId } ); if (apiResponse != null) { Scheda.ActivityId = apiResponse.ActivityIdScheda; SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione; await IspezioniService.UpdateActivityIdIspezioneAsync(Ispezione.CodMdep, Ispezione.Data, UserSession.User.Username, apiResponse.ActivityIdIspezione ); await IspezioniService.UpdateActivityIdSchedaAsync(Scheda.Id, Scheda.ActivityId); } VisibleOverlay = false; StateHasChanged(); } private async Task ExportImg() { if (Scheda.ImageNames == null) return; var fileList = (await FileManager.GetInspectionFiles(Ispezione, Scheda.ImageNames))? .Where(x => x.ToUpload).ToList(); if (fileList == null) return; foreach (var file in fileList) { await IntegrySteupService.UploadFile(Scheda.ActivityId!, file.FileBytes!, file.Name!); } } }