From a5931411855e83ac75942cd0c371489e479cd1fc Mon Sep 17 00:00:00 2001 From: MarcoE Date: Thu, 30 Oct 2025 09:33:48 +0100 Subject: [PATCH] =?UTF-8?q?Aggiunta=20possibilit=C3=A0=20che=20dalla=20com?= =?UTF-8?q?messa=20viene=20selezionato=20il=20cliente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SingleElements/Modal/ActivityForm.razor | 170 ++++++++++-------- .../Core/Entity/StbActivityTyper.cs | 18 ++ 2 files changed, 115 insertions(+), 73 deletions(-) create mode 100644 salesbook.Shared/Core/Entity/StbActivityTyper.cs diff --git a/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor b/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor index 364ef47..41188ea 100644 --- a/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor +++ b/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor @@ -20,17 +20,21 @@ - +
- +
@@ -46,7 +50,6 @@ else { Inizio - +
@@ -74,7 +80,10 @@
Fine - +
@@ -82,14 +91,31 @@
Avviso - - Nessuno - All'ora pianificata - 30 minuti prima - 1 ora prima - 2 ore prima - 1 giorno prima - 1 settimana prima + + + Nessuno + + All'ora + pianificata + + + 30 minuti prima + + + 1 ora prima + + + 2 ore prima + + + 1 giorno prima + + + 1 settimana prima +
@@ -132,10 +158,14 @@ } else { - + @foreach (var type in ActivityType) { - @type.ActivityTypeId + @type.ActivityTypeId } } @@ -146,17 +176,23 @@
Esito - + @foreach (var result in ActivityResult) { - @result.ActivityResultId + @result.ActivityResultId }
- +
@@ -166,13 +202,15 @@ { @if (item.p.Type == AttachedDTO.TypeAttached.Position) { - + @item.p.Description } else { - + @item.p.Name } @@ -183,7 +221,7 @@ { foreach (var file in ActivityFileList) { - + @file.FileName } @@ -246,7 +284,8 @@ - + @@ -400,25 +439,7 @@ SelectedUser = Users.FindLast(x => x.UserName.Equals(ActivityModel.UserName)); if (!IsNew && Id != null) - { ActivityFileList = await IntegryApiService.GetActivityFile(Id); - if (ActivityModel.IdPosizione != null) - { - ActivityModel.Position = await IntegryApiService.RetrievePosition(ActivityModel.IdPosizione.Value); - CanAddPosition = false; - - AttachedList ??= []; - AttachedList.Add( - new AttachedDTO - { - Name = ActivityModel.Position.Description!, - Lat = ActivityModel.Position.Lat, - Lng = ActivityModel.Position.Lng, - Type = AttachedDTO.TypeAttached.Position - } - ); - } - } ActivityResult = await ManageData.GetTable(); Clienti = await ManageData.GetClienti(new WhereCondContact { FlagStato = "A" }); @@ -440,18 +461,29 @@ ); } - private async Task LoadCommesse() + private async Task LoadCommesse(string searchValue) { - if (_lastLoadedCodAnag == ActivityModel.CodAnag) return; + if (_lastLoadedCodAnag == ActivityModel.CodAnag && searchValue.IsNullOrEmpty()) return; + + if (ActivityModel.CodAnag == null) + { + Commesse = await ManageData.GetTable(x => + x.CodJcom.Contains(searchValue) || + x.Descrizione.Contains(searchValue) + ); + } + else + { + Commesse = await ManageData.GetTable(x => x.CodAnag == ActivityModel.CodAnag); + } - Commesse = await ManageData.GetTable(x => x.CodAnag == ActivityModel.CodAnag); Commesse = Commesse.OrderByDescending(x => x.CodJcom).ToList(); _lastLoadedCodAnag = ActivityModel.CodAnag; } private async Task> SearchCommesseAsync(string value, CancellationToken token) { - await LoadCommesse(); + await LoadCommesse(value); if (Commesse.IsNullOrEmpty()) return []; IEnumerable list; @@ -527,18 +559,37 @@ return Task.CompletedTask; } - private async Task OnCommessaSelectedAfter() + private void OnCommessaSelectedAfter() { var com = SelectedComessa; if (com != null) { ActivityModel.CodJcom = com.CodJcom; ActivityModel.Commessa = com; + + if (com.CodAnag != null) + { + ActivityModel.CodAnag = com.CodAnag; + ActivityModel.Cliente = Clienti + .Where(x => x.CodAnag != null && x.CodAnag.Equals(com.CodAnag)) + .Select(x => x.RagSoc) + .FirstOrDefault() ?? Pros + .Where(x => x.CodPpro != null && x.CodPpro.Equals(com.CodAnag)) + .Select(x => x.RagSoc) + .FirstOrDefault(); + } + else + { + ActivityModel.CodAnag = null; + ActivityModel.Cliente = null; + } } else { ActivityModel.CodJcom = null; ActivityModel.Commessa = null; + ActivityModel.CodAnag = null; + ActivityModel.Cliente = null; } OnAfterChangeValue(); @@ -700,33 +751,6 @@ } } - private async Task DeleteAttach(ActivityFileDto file) - { - Snackbar.Clear(); - - if (ActivityFileList == null) return; - - try - { - ActivityFileList.Remove(file); - StateHasChanged(); - - await IntegryApiService.DeleteFile(ActivityModel.ActivityId!, file.FileName); - } - catch (Exception ex) - { - ActivityFileList.Add(file); - StateHasChanged(); - - Snackbar.Add("Impossibile eliminare il file", Severity.Error); - Console.WriteLine($"Impossibile eliminare il file: {ex.Message}"); - } - finally - { - Snackbar.Add($"{file.FileName} eliminato con successo", Severity.Info); - } - } - private async Task OpenAttached(AttachedDTO attached) { if (attached is { FileContent: not null, MimeType: not null }) diff --git a/salesbook.Shared/Core/Entity/StbActivityTyper.cs b/salesbook.Shared/Core/Entity/StbActivityTyper.cs new file mode 100644 index 0000000..34434e1 --- /dev/null +++ b/salesbook.Shared/Core/Entity/StbActivityTyper.cs @@ -0,0 +1,18 @@ +using System.Text.Json.Serialization; + +namespace salesbook.Shared.Core.Entity; + +public class StbActivityTyper +{ + [JsonPropertyName("activityTypeId")] + public string? ActivityTypeId { get; set; } + + [JsonPropertyName("activityTypeDescription")] + public string? ActivityTypeDescription { get; set; } + + [JsonPropertyName("flagTipologia")] + public string? FlagTipologia { get; set; } + + [JsonPropertyName("idRiga")] + public int IdRiga { get; set; } +} \ No newline at end of file