From a34e673cd23258cc752910cd92c0a121a63921d5 Mon Sep 17 00:00:00 2001 From: MarcoE Date: Thu, 26 Jun 2025 09:26:50 +0200 Subject: [PATCH] =?UTF-8?q?Cancellazione=20attivit=C3=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Template.Maui/App.xaml.cs | 9 +- Template.Maui/Core/Services/LocalDbService.cs | 4 + .../Core/Services/ManageDataService.cs | 10 ++ Template.Maui/MainPage.xaml.cs | 9 +- Template.Maui/MauiProgram.cs | 18 ++- Template.Maui/Platforms/Windows/App.xaml | 8 -- Template.Maui/Platforms/Windows/App.xaml.cs | 25 ---- .../Platforms/Windows/Package.appxmanifest | 46 ------- Template.Maui/Platforms/Windows/app.manifest | 15 --- Template.Maui/Resources/AppIcon/appiconfg.svg | 2 +- Template.Maui/Resources/Splash/splash.svg | 22 ++-- Template.Maui/Template.Maui.csproj | 31 +++-- .../Components/Layout/MainLayout.razor | 4 +- .../Components/Layout/NavMenu.razor | 23 +++- .../Components/Pages/Calendar.razor | 79 +++++++++--- .../Components/Pages/PersonalInfo.razor.css | 50 +------- .../SingleElements/Card/ActivityCard.razor | 12 +- .../SingleElements/ExceptionModal.razor.css | 2 +- .../SingleElements/Modal/ActivityForm.razor | 116 ++++++++++++++++-- .../Modal/ActivityForm.razor.css | 4 + Template.Shared/Core/Dto/ActivityDTO.cs | 2 + Template.Shared/Core/Helpers/ModalHelpers.cs | 6 +- .../Core/Interface/IIntegryApiService.cs | 2 + .../Core/Interface/IManageDataService.cs | 3 + .../Activity/Copy/CopyActivityMessage.cs | 6 + .../Activity/Copy/CopyActivityService.cs | 17 +++ .../Activity/New/NewActivityMessage.cs | 5 + .../Activity/New/NewActivityService.cs | 16 +++ .../{ => Back}/BackNavigationService.cs | 6 +- .../{ => Back}/HardwareBackMessage.cs | 2 +- .../Core/Services/IntegryApiService.cs | 12 +- Template.Shared/wwwroot/css/app.css | 9 ++ Template.Shared/wwwroot/css/default-theme.css | 2 +- Template.Shared/wwwroot/css/form.css | 67 ++++++++++ .../salesbook-marchio_vers.positiva.svg | 22 ++-- Template.Shared/wwwroot/js/main.js | 1 + .../Core/Services/ManageDataService.cs | 5 + Template.Web/Program.cs | 2 - 38 files changed, 443 insertions(+), 231 deletions(-) delete mode 100644 Template.Maui/Platforms/Windows/App.xaml delete mode 100644 Template.Maui/Platforms/Windows/App.xaml.cs delete mode 100644 Template.Maui/Platforms/Windows/Package.appxmanifest delete mode 100644 Template.Maui/Platforms/Windows/app.manifest create mode 100644 Template.Shared/Core/Messages/Activity/Copy/CopyActivityMessage.cs create mode 100644 Template.Shared/Core/Messages/Activity/Copy/CopyActivityService.cs create mode 100644 Template.Shared/Core/Messages/Activity/New/NewActivityMessage.cs create mode 100644 Template.Shared/Core/Messages/Activity/New/NewActivityService.cs rename Template.Shared/Core/Messages/{ => Back}/BackNavigationService.cs (54%) rename Template.Shared/Core/Messages/{ => Back}/HardwareBackMessage.cs (63%) diff --git a/Template.Maui/App.xaml.cs b/Template.Maui/App.xaml.cs index adb6280..12dd76d 100644 --- a/Template.Maui/App.xaml.cs +++ b/Template.Maui/App.xaml.cs @@ -1,15 +1,20 @@ +using CommunityToolkit.Mvvm.Messaging; + namespace Template.Maui { public partial class App : Application { - public App() + private readonly IMessenger _messenger; + + public App(IMessenger messenger) { InitializeComponent(); + _messenger = messenger; } protected override Window CreateWindow(IActivationState? activationState) { - return new Window(new MainPage()); + return new Window(new MainPage(_messenger)); } } } diff --git a/Template.Maui/Core/Services/LocalDbService.cs b/Template.Maui/Core/Services/LocalDbService.cs index 509dd48..d603bb3 100644 --- a/Template.Maui/Core/Services/LocalDbService.cs +++ b/Template.Maui/Core/Services/LocalDbService.cs @@ -1,6 +1,7 @@ using SQLite; using System.Linq.Expressions; using Template.Shared.Core.Entity; + namespace Template.Maui.Core.Services; public class LocalDbService @@ -110,4 +111,7 @@ public class LocalDbService : _connection.Table().Where(whereCond).ToListAsync(); public List Get(string sql) where T : new() => _connection.QueryAsync(sql).Result; + + public async Task Delete(T entity) => + await _connection.DeleteAsync(entity); } \ No newline at end of file diff --git a/Template.Maui/Core/Services/ManageDataService.cs b/Template.Maui/Core/Services/ManageDataService.cs index 1f1b149..3b2d70d 100644 --- a/Template.Maui/Core/Services/ManageDataService.cs +++ b/Template.Maui/Core/Services/ManageDataService.cs @@ -72,6 +72,16 @@ public class ManageDataService(LocalDbService localDb, IMapper mapper) : IManage public Task InsertOrUpdate(T objectToSave) => localDb.InsertOrUpdate([objectToSave]); + public Task Delete(T objectToDelete) => + localDb.Delete(objectToDelete); + + public async Task DeleteActivity(ActivityDTO activity) + { + await localDb.Delete( + (await GetTable(x => x.ActivityId.Equals(activity.ActivityId))).Last() + ); + } + public Task ClearDb() => localDb.ResetDb(); } \ No newline at end of file diff --git a/Template.Maui/MainPage.xaml.cs b/Template.Maui/MainPage.xaml.cs index 71d0780..7fb2108 100644 --- a/Template.Maui/MainPage.xaml.cs +++ b/Template.Maui/MainPage.xaml.cs @@ -1,18 +1,21 @@ using CommunityToolkit.Mvvm.Messaging; -using Template.Shared.Core.Messages; +using Template.Shared.Core.Messages.Back; namespace Template.Maui { public partial class MainPage : ContentPage { - public MainPage() + private readonly IMessenger _messenger; + + public MainPage(IMessenger messenger) { InitializeComponent(); + _messenger = messenger; } protected override bool OnBackButtonPressed() { - WeakReferenceMessenger.Default.Send(new HardwareBackMessage("back")); + _messenger.Send(new HardwareBackMessage("back")); return true; } diff --git a/Template.Maui/MauiProgram.cs b/Template.Maui/MauiProgram.cs index a8d4cbf..a5fdae4 100644 --- a/Template.Maui/MauiProgram.cs +++ b/Template.Maui/MauiProgram.cs @@ -1,4 +1,5 @@ using CommunityToolkit.Maui; +using CommunityToolkit.Mvvm.Messaging; using IntegryApiClient.MAUI; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.Extensions.Logging; @@ -8,7 +9,10 @@ using Template.Maui.Core.Services; using Template.Shared; using Template.Shared.Core.Helpers; using Template.Shared.Core.Interface; -using Template.Shared.Core.Messages; +using Template.Shared.Core.Messages.Activity; +using Template.Shared.Core.Messages.Activity.Copy; +using Template.Shared.Core.Messages.Activity.New; +using Template.Shared.Core.Messages.Back; using Template.Shared.Core.Services; namespace Template.Maui @@ -25,10 +29,7 @@ namespace Template.Maui builder .UseMauiApp() .UseMauiCommunityToolkit() - .ConfigureFonts(fonts => - { - fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); - }) + .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); }) .UseLoginAzienda(AppToken); builder.Services.AddMauiBlazorWebView(); @@ -46,7 +47,12 @@ namespace Template.Maui builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); + + //Message + builder.Services.AddScoped(); + builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddScoped(); #if DEBUG builder.Services.AddBlazorWebViewDeveloperTools(); @@ -59,4 +65,4 @@ namespace Template.Maui return builder.Build(); } } -} +} \ No newline at end of file diff --git a/Template.Maui/Platforms/Windows/App.xaml b/Template.Maui/Platforms/Windows/App.xaml deleted file mode 100644 index 5b5885b..0000000 --- a/Template.Maui/Platforms/Windows/App.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - diff --git a/Template.Maui/Platforms/Windows/App.xaml.cs b/Template.Maui/Platforms/Windows/App.xaml.cs deleted file mode 100644 index 957515f..0000000 --- a/Template.Maui/Platforms/Windows/App.xaml.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.UI.Xaml; - -// To learn more about WinUI, the WinUI project structure, -// and more about our project templates, see: http://aka.ms/winui-project-info. - -namespace Template.Maui.WinUI -{ - /// - /// Provides application-specific behavior to supplement the default Application class. - /// - public partial class App : MauiWinUIApplication - { - /// - /// Initializes the singleton application object. This is the first line of authored code - /// executed, and as such is the logical equivalent of main() or WinMain(). - /// - public App() - { - this.InitializeComponent(); - } - - protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); - } - -} diff --git a/Template.Maui/Platforms/Windows/Package.appxmanifest b/Template.Maui/Platforms/Windows/Package.appxmanifest deleted file mode 100644 index 443d058..0000000 --- a/Template.Maui/Platforms/Windows/Package.appxmanifest +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - $placeholder$ - User Name - $placeholder$.png - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Template.Maui/Platforms/Windows/app.manifest b/Template.Maui/Platforms/Windows/app.manifest deleted file mode 100644 index 7e2916c..0000000 --- a/Template.Maui/Platforms/Windows/app.manifest +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - true/PM - PerMonitorV2, PerMonitor - - - diff --git a/Template.Maui/Resources/AppIcon/appiconfg.svg b/Template.Maui/Resources/AppIcon/appiconfg.svg index beb8682..abe196b 100644 --- a/Template.Maui/Resources/AppIcon/appiconfg.svg +++ b/Template.Maui/Resources/AppIcon/appiconfg.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/Template.Maui/Resources/Splash/splash.svg b/Template.Maui/Resources/Splash/splash.svg index 23cbbe4..d9bbd1e 100644 --- a/Template.Maui/Resources/Splash/splash.svg +++ b/Template.Maui/Resources/Splash/splash.svg @@ -23,18 +23,18 @@ - - - - - - - - - + + + + + + + + + - - + + \ No newline at end of file diff --git a/Template.Maui/Template.Maui.csproj b/Template.Maui/Template.Maui.csproj index 02b1387..de4891b 100644 --- a/Template.Maui/Template.Maui.csproj +++ b/Template.Maui/Template.Maui.csproj @@ -23,7 +23,7 @@ enable - sales book + salesbook it.integry.template.maui @@ -55,7 +55,8 @@ - + - + true true true - + 14.2 $(DefineConstants);APPLE;PLATFORM - Apple Development: Created via API (5B7B69P4JY) - VS: WildCard Development + Apple Development: Created via API (5B7B69P4JY) + VS: WildCard Development - + - - - + + + + + + + + + + diff --git a/Template.Shared/Components/Layout/MainLayout.razor b/Template.Shared/Components/Layout/MainLayout.razor index fc60a41..e6ff4ed 100644 --- a/Template.Shared/Components/Layout/MainLayout.razor +++ b/Template.Shared/Components/Layout/MainLayout.razor @@ -1,7 +1,9 @@ @using System.Globalization -@using Template.Shared.Core.Messages +@using CommunityToolkit.Mvvm.Messaging +@using Template.Shared.Core.Messages.Back @inherits LayoutComponentBase @inject IJSRuntime JS +@inject IMessenger Messenger @inject BackNavigationService BackService diff --git a/Template.Shared/Components/Layout/NavMenu.razor b/Template.Shared/Components/Layout/NavMenu.razor index f06e737..602867a 100644 --- a/Template.Shared/Components/Layout/NavMenu.razor +++ b/Template.Shared/Components/Layout/NavMenu.razor @@ -1,4 +1,11 @@ +@using CommunityToolkit.Mvvm.Messaging +@using Template.Shared.Core.Dto +@using Template.Shared.Core.Entity +@using Template.Shared.Core.Messages.Activity.Copy +@using Template.Shared.Core.Messages.Activity.New @inject IDialogService Dialog +@inject IMessenger Messenger +@inject CopyActivityService CopyActivityService