diff --git a/salesbook.Maui/Core/Services/ManageDataService.cs b/salesbook.Maui/Core/Services/ManageDataService.cs
index 6bd036e..a0470f6 100644
--- a/salesbook.Maui/Core/Services/ManageDataService.cs
+++ b/salesbook.Maui/Core/Services/ManageDataService.cs
@@ -48,7 +48,7 @@ public class ManageDataService(LocalDbService localDb, IMapper mapper) : IManage
dto.Category = activity.CodAnag != null ? ActivityCategoryEnum.Interna : ActivityCategoryEnum.Memo;
}
- if (dto.Category == ActivityCategoryEnum.Interna && activity.CodAnag != null)
+ if (dto.Category != ActivityCategoryEnum.Memo && activity.CodAnag != null)
{
string? ragSoc;
diff --git a/salesbook.Maui/MauiProgram.cs b/salesbook.Maui/MauiProgram.cs
index 5334091..32b4cc2 100644
--- a/salesbook.Maui/MauiProgram.cs
+++ b/salesbook.Maui/MauiProgram.cs
@@ -9,7 +9,6 @@ using salesbook.Maui.Core.Services;
using salesbook.Shared;
using salesbook.Shared.Core.Helpers;
using salesbook.Shared.Core.Interface;
-using salesbook.Shared.Core.Messages.Activity;
using salesbook.Shared.Core.Messages.Activity.Copy;
using salesbook.Shared.Core.Messages.Activity.New;
using salesbook.Shared.Core.Messages.Back;
diff --git a/salesbook.Shared/Components/SingleElements/BottomSheet/SelectEsito.razor b/salesbook.Shared/Components/SingleElements/BottomSheet/SelectEsito.razor
index b6b1810..670159d 100644
--- a/salesbook.Shared/Components/SingleElements/BottomSheet/SelectEsito.razor
+++ b/salesbook.Shared/Components/SingleElements/BottomSheet/SelectEsito.razor
@@ -1,4 +1,5 @@
-@using salesbook.Shared.Core.Dto
+@using System.Threading.Channels
+@using salesbook.Shared.Core.Dto
@using salesbook.Shared.Core.Entity
@using salesbook.Shared.Core.Interface
@inject IManageDataService ManageData
@@ -26,7 +27,7 @@
Inizio
-
+
@@ -34,7 +35,7 @@
Fine
-
+
@@ -56,7 +57,7 @@
- Salva
+ Salva
@@ -90,20 +91,44 @@
StateHasChanged();
}
- private void CloseBottomSheet()
+ private void CloseBottomSheet(bool save)
{
- if (EffectiveDate != null)
+ if (save)
{
- ActivityModel.EffectiveTime = new DateTime(EffectiveDate!.Value.Year, EffectiveDate!.Value.Month, EffectiveDate!.Value.Day,
- EffectiveTime.Hours, EffectiveTime.Minutes, EffectiveTime.Seconds);
+ if (EffectiveDate != null)
+ {
+ ActivityModel.EffectiveTime = new DateTime(EffectiveDate!.Value.Year, EffectiveDate!.Value.Month, EffectiveDate!.Value.Day,
+ EffectiveTime.Hours, EffectiveTime.Minutes, EffectiveTime.Seconds);
- ActivityModel.EffectiveEndtime = new DateTime(EffectiveDate!.Value.Year, EffectiveDate!.Value.Month, EffectiveDate!.Value.Day,
- EffectiveEndTime.Hours, EffectiveEndTime.Minutes, EffectiveEndTime.Seconds);
+ ActivityModel.EffectiveEndtime = new DateTime(EffectiveDate!.Value.Year, EffectiveDate!.Value.Month, EffectiveDate!.Value.Day,
+ EffectiveEndTime.Hours, EffectiveEndTime.Minutes, EffectiveEndTime.Seconds);
+ }
+
+ if (ActivityModel.ActivityResultId.IsNullOrEmpty())
+ {
+ Snackbar.Clear();
+ Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
+
+ Snackbar.Add("Esito obbligatorio!", Severity.Error);
+ return;
+ }
}
IsSheetVisible = false;
IsSheetVisibleChanged.InvokeAsync(IsSheetVisible);
- ActivityModelChanged.InvokeAsync(ActivityModel);
+
+ if (save)
+ {
+ ActivityModelChanged.InvokeAsync(ActivityModel);
+ }
+ }
+
+ private void CloseBottomSheet() => CloseBottomSheet(false);
+
+ private void OnAfterChangeTime()
+ {
+ if (EffectiveEndTime < EffectiveTime)
+ EffectiveEndTime = EffectiveTime + TimeSpan.FromHours(1);
}
}
\ No newline at end of file
diff --git a/salesbook.Shared/Components/SingleElements/Card/ActivityCard.razor b/salesbook.Shared/Components/SingleElements/Card/ActivityCard.razor
index 803cb88..b81a5f6 100644
--- a/salesbook.Shared/Components/SingleElements/Card/ActivityCard.razor
+++ b/salesbook.Shared/Components/SingleElements/Card/ActivityCard.razor
@@ -69,7 +69,7 @@
private TimeSpan? Durata { get; set; }
- protected override void OnInitialized()
+ protected override void OnParametersSet()
{
Durata = Activity switch
{
diff --git a/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor b/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor
index 2adcf13..dab39d0 100644
--- a/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor
+++ b/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor
@@ -1,4 +1,5 @@
@using System.Globalization
+@using System.Text.RegularExpressions
@using CommunityToolkit.Mvvm.Messaging
@using salesbook.Shared.Core.Dto
@using salesbook.Shared.Components.Layout
@@ -203,6 +204,8 @@
ActivityModel = ActivityCopied.Clone();
}
+ await LoadCommesse();
+
if (IsNew)
{
ActivityModel.EstimatedTime = DateTime.Today.Add(TimeSpan.FromHours(DateTime.Now.Hour));
@@ -255,7 +258,6 @@
Clienti = await ManageData.GetTable(x => x.FlagStato.Equals("A"));
Pros = await ManageData.GetTable();
ActivityType = await ManageData.GetTable(x => x.FlagTipologia.Equals("A"));
- await LoadCommesse();
}
private async Task LoadCommesse() =>
@@ -281,31 +283,19 @@
private async Task OnClienteChanged()
{
- string? codAnag = null;
ActivityModel.CodJcom = null;
- var cliente = Clienti.LastOrDefault(x => ActivityModel.Cliente != null && x.RagSoc.Contains(ActivityModel.Cliente, StringComparison.OrdinalIgnoreCase));
- if (cliente is null)
- {
- var pros = Pros.LastOrDefault(x => ActivityModel.Cliente != null && x.RagSoc.Contains(ActivityModel.Cliente, StringComparison.OrdinalIgnoreCase));
+ if (ActivityModel.Cliente.IsNullOrEmpty()) return;
- if (pros is not null)
- {
- codAnag = pros.CodAnag;
- }
- }
- else
- {
- codAnag = cliente.CodAnag;
- }
+ var match = Regex.Match(ActivityModel.Cliente!, @"^\s*(\S+)\s*-\s*(.*)$");
+ if (!match.Success)
+ return;
+ ActivityModel.CodAnag = match.Groups[1].Value;
+ ActivityModel.Cliente = match.Groups[2].Value;
- if (codAnag is not null)
- {
- ActivityModel.CodAnag = codAnag;
- await LoadCommesse();
- OnAfterChangeValue();
- }
+ await LoadCommesse();
+ OnAfterChangeValue();
}
private async Task OnCommessaChanged()
@@ -320,6 +310,11 @@
{
LabelSave = !OriginalModel.Equals(ActivityModel) ? "Aggiorna" : null;
}
+
+ if (ActivityModel.EstimatedEndtime <= ActivityModel.EstimatedTime)
+ {
+ ActivityModel.EstimatedEndtime = ActivityModel.EstimatedTime.Value.AddHours(1);
+ }
}
private void OpenSelectEsito()