Aggiunta cancellazione ispezione
This commit is contained in:
@@ -117,6 +117,10 @@ public class IspezioniService(AppDbContext db) : IIspezioniService
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<bool> DeleteIspezioneAsync(string codMdep, DateTime data, string rilevatore)
|
public async Task<bool> DeleteIspezioneAsync(string codMdep, DateTime data, string rilevatore)
|
||||||
{
|
{
|
||||||
|
var schede = await GetAllSchedeOfIspezioneAsync(codMdep, data, rilevatore);
|
||||||
|
if (schede.Count > 0)
|
||||||
|
throw new Exception("Impossibile cancellare l'ispezione perché ci sono schede collegate. Cancellare prima le schede.");
|
||||||
|
|
||||||
var ispezione = await db.Ispezioni
|
var ispezione = await db.Ispezioni
|
||||||
.FirstOrDefaultAsync(x =>
|
.FirstOrDefaultAsync(x =>
|
||||||
x.CodMdep == codMdep &&
|
x.CodMdep == codMdep &&
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
@using SteUp.Shared.Core.Helpers
|
@inject IJSRuntime Js
|
||||||
@inject IJSRuntime Js
|
|
||||||
|
|
||||||
<div class="@(Back ? "" : "container") header">
|
<div class="@(Back ? "" : "container") header">
|
||||||
<div class="header-content @(Back ? "with-back" : "no-back")">
|
<div class="header-content @(Back ? "with-back" : "no-back")">
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
@using CommunityToolkit.Mvvm.Messaging
|
@using CommunityToolkit.Mvvm.Messaging
|
||||||
@using SteUp.Shared.Components.SingleElements.MessageBox
|
@using SteUp.Shared.Components.SingleElements.MessageBox
|
||||||
@using SteUp.Shared.Core.Enum
|
@using SteUp.Shared.Core.Enum
|
||||||
|
@using SteUp.Shared.Core.Interface.LocalDb
|
||||||
@using SteUp.Shared.Core.Messages.Ispezione
|
@using SteUp.Shared.Core.Messages.Ispezione
|
||||||
@using SteUp.Shared.Core.Messages.Scheda
|
@using SteUp.Shared.Core.Messages.Scheda
|
||||||
@inject INetworkService NetworkService
|
@inject INetworkService NetworkService
|
||||||
@inject IDialogService Dialog
|
@inject IDialogService Dialog
|
||||||
@inject IMessenger Messenger
|
@inject IMessenger Messenger
|
||||||
|
@inject IIspezioniService IspezioniService
|
||||||
|
@inject IJSRuntime Js
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="container animated-navbar @(IsVisible ? "show-nav" : "hide-nav") @(IsVisible ? PlusVisible ? "with-plus" : "without-plus" : "with-plus")">
|
class="container animated-navbar @(IsVisible ? "show-nav" : "hide-nav") @(IsVisible ? PlusVisible ? "with-plus" : "without-plus" : "with-plus")">
|
||||||
@@ -42,6 +45,9 @@
|
|||||||
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewScheda"
|
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewScheda"
|
||||||
Label="Nuova scheda" Color="Color.Surface"/>
|
Label="Nuova scheda" Color="Color.Surface"/>
|
||||||
|
|
||||||
|
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@DeleteInspection"
|
||||||
|
Label="Cancella ispezione" Color="Color.Surface"/>
|
||||||
|
|
||||||
if (ShowCompleteInspection)
|
if (ShowCompleteInspection)
|
||||||
{
|
{
|
||||||
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@CompleteInspection"
|
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@CompleteInspection"
|
||||||
@@ -135,4 +141,19 @@
|
|||||||
ShowCompleteInspection = !SteupDataService.InspectionPageState.Ispezione.ActivityId.IsNullOrEmpty();
|
ShowCompleteInspection = !SteupDataService.InspectionPageState.Ispezione.ActivityId.IsNullOrEmpty();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task DeleteInspection()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ispezione = SteupDataService.InspectionPageState.Ispezione;
|
||||||
|
await IspezioniService.DeleteIspezioneAsync(ispezione.CodMdep, ispezione.Data, ispezione.Rilevatore);
|
||||||
|
|
||||||
|
await Js.InvokeVoidAsync("goBack");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
await Dialog.ShowError(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user