From c93b0c9bec6d914df1423af7299fc6af652ec7d6 Mon Sep 17 00:00:00 2001 From: MarcoE Date: Wed, 6 Aug 2025 12:31:52 +0200 Subject: [PATCH] Fix vari --- .../Core/Services/ManageDataService.cs | 11 +++++-- salesbook.Shared/Components/Pages/User.razor | 16 ++++++++++ .../BottomSheet/SearchAddress.razor | 2 +- .../SingleElements/Modal/ActivityForm.razor | 25 +++++++++++++-- .../SingleElements/Modal/ContactForm.razor | 2 ++ salesbook.Shared/Core/Dto/ActivityFileDto.cs | 24 ++++++++++++++ .../Core/Dto/CRMCreateContactResponseDTO.cs | 6 ++++ .../Core/Dto/CRMTransferProspectRequestDTO.cs | 12 +++++++ .../Dto/CRMTransferProspectResponseDTO.cs | 10 ++++++ salesbook.Shared/Core/Entity/PtbProsRif.cs | 32 +++++++++++++++++-- salesbook.Shared/Core/Entity/StbActivity.cs | 2 +- .../Core/Entity/StbActivityType.cs | 32 +++++++++++++++++-- .../Core/Entity/VtbCliePersRif.cs | 32 +++++++++++++++++-- salesbook.Shared/Core/Entity/VtbDest.cs | 32 +++++++++++++++++-- .../Core/Interface/IIntegryApiService.cs | 5 ++- .../Core/Interface/IManageDataService.cs | 1 + .../Core/Services/IntegryApiService.cs | 18 ++++++++++- .../Core/Services/ManageDataService.cs | 5 +++ 18 files changed, 249 insertions(+), 18 deletions(-) create mode 100644 salesbook.Shared/Core/Dto/ActivityFileDto.cs create mode 100644 salesbook.Shared/Core/Dto/CRMTransferProspectRequestDTO.cs create mode 100644 salesbook.Shared/Core/Dto/CRMTransferProspectResponseDTO.cs diff --git a/salesbook.Maui/Core/Services/ManageDataService.cs b/salesbook.Maui/Core/Services/ManageDataService.cs index ec0045a..74f2a98 100644 --- a/salesbook.Maui/Core/Services/ManageDataService.cs +++ b/salesbook.Maui/Core/Services/ManageDataService.cs @@ -22,7 +22,7 @@ public class ManageDataService(LocalDbService localDb, IMapper mapper) : IManage // Mappa i prospects var prospectMapper = mapper.Map>(prospectList); - + contactMapper.AddRange(prospectMapper); return contactMapper; @@ -32,13 +32,15 @@ public class ManageDataService(LocalDbService localDb, IMapper mapper) : IManage { if (isContact) { - var contact = (await localDb.Get(x => x.CodAnag != null && x.CodAnag.Equals(codAnag))).LastOrDefault(); + var contact = (await localDb.Get(x => x.CodAnag != null && x.CodAnag.Equals(codAnag))) + .LastOrDefault(); return contact == null ? null : mapper.Map(contact); } else { - var contact = (await localDb.Get(x => x.CodPpro != null && x.CodPpro.Equals(codAnag))).LastOrDefault(); + var contact = (await localDb.Get(x => x.CodPpro != null && x.CodPpro.Equals(codAnag))) + .LastOrDefault(); return contact == null ? null : mapper.Map(contact); } @@ -101,6 +103,9 @@ public class ManageDataService(LocalDbService localDb, IMapper mapper) : IManage return returnDto; } + public Task InsertOrUpdate(List listToSave) => + localDb.InsertOrUpdate(listToSave); + public Task InsertOrUpdate(T objectToSave) => localDb.InsertOrUpdate([objectToSave]); diff --git a/salesbook.Shared/Components/Pages/User.razor b/salesbook.Shared/Components/Pages/User.razor index 41a1797..015ca26 100644 --- a/salesbook.Shared/Components/Pages/User.razor +++ b/salesbook.Shared/Components/Pages/User.razor @@ -75,6 +75,16 @@ else } + + @if (Agente != null) + { +
+ Agente + + @Agente.FullName + +
+ } @@ -131,6 +141,7 @@ else private ContactDTO Anag { get; set; } = new(); private List? PersRif { get; set; } private List Commesse { get; set; } + private StbUser? Agente { get; set; } private bool IsLoading { get; set; } = true; @@ -160,6 +171,11 @@ else Commesse = await ManageData.GetTable(x => x.CodAnag != null && x.CodAnag.Equals(CodContact)); + if (Anag.CodVage != null) + { + Agente = (await ManageData.GetTable(x => x.UserCode != null && x.UserCode.Equals(Anag.CodVage))).LastOrDefault(); + } + IsLoading = false; StateHasChanged(); } diff --git a/salesbook.Shared/Components/SingleElements/BottomSheet/SearchAddress.razor b/salesbook.Shared/Components/SingleElements/BottomSheet/SearchAddress.razor index 9ec722a..44a29f7 100644 --- a/salesbook.Shared/Components/SingleElements/BottomSheet/SearchAddress.razor +++ b/salesbook.Shared/Components/SingleElements/BottomSheet/SearchAddress.razor @@ -39,7 +39,7 @@ } else { - + } } diff --git a/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor b/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor index 08f1bda..e35b0bd 100644 --- a/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor +++ b/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor @@ -128,6 +128,16 @@ } } + + @if (ActivityFileList != null) + { + foreach (var file in ActivityFileList) + { + + @file.FileName + + } + }
@@ -214,6 +224,7 @@ private List Commesse { get; set; } = []; private List Clienti { get; set; } = []; private List Pros { get; set; } = []; + private List? ActivityFileList { get; set; } private bool IsNew => Id.IsNullOrEmpty(); private bool IsView => !NetworkService.IsNetworkAvailable(); @@ -336,6 +347,11 @@ private async Task LoadData() { + if (!IsNew && Id != null) + { + ActivityFileList = await IntegryApiService.GetActivityFile(Id); + } + Users = await ManageData.GetTable(); ActivityResult = await ManageData.GetTable(); Clienti = await ManageData.GetTable(x => x.FlagStato.Equals("A")); @@ -404,10 +420,10 @@ { OnAfterChangeValue(); - var result = await ConfirmMemo.ShowAsync(); + // var result = await ConfirmMemo.ShowAsync(); - if (result is true) - OpenAddMemo = !OpenAddMemo; + // if (result is true) + // OpenAddMemo = !OpenAddMemo; } private void OpenSelectEsito() @@ -455,6 +471,7 @@ private void Duplica() { var activityCopy = ActivityModel.Clone(); + activityCopy.ActivityId = null; MudDialog.Cancel(); Messenger.Send(new CopyActivityMessage(activityCopy)); @@ -468,6 +485,8 @@ { AttachedList ??= []; AttachedList.Add((AttachedDTO)result.Data); + + LabelSave = "Aggiorna"; } } diff --git a/salesbook.Shared/Components/SingleElements/Modal/ContactForm.razor b/salesbook.Shared/Components/SingleElements/Modal/ContactForm.razor index 0b0c111..7985f88 100644 --- a/salesbook.Shared/Components/SingleElements/Modal/ContactForm.razor +++ b/salesbook.Shared/Components/SingleElements/Modal/ContactForm.razor @@ -380,9 +380,11 @@ return; case {AnagClie: null, PtbPros: not null}: await ManageData.InsertOrUpdate(response.PtbPros); + await ManageData.InsertOrUpdate(response.PtbProsRif); break; case { AnagClie: not null, PtbPros: null }: await ManageData.InsertOrUpdate(response.AnagClie); + await ManageData.InsertOrUpdate(response.VtbCliePersRif); break; default: VisibleOverlay = false; diff --git a/salesbook.Shared/Core/Dto/ActivityFileDto.cs b/salesbook.Shared/Core/Dto/ActivityFileDto.cs new file mode 100644 index 0000000..0e37218 --- /dev/null +++ b/salesbook.Shared/Core/Dto/ActivityFileDto.cs @@ -0,0 +1,24 @@ +using System.Text.Json.Serialization; + +namespace salesbook.Shared.Core.Dto; + +public class ActivityFileDto +{ + [JsonPropertyName("id")] + public string Id { get; set; } + + [JsonPropertyName("fileName")] + public string FileName { get; set; } + + [JsonPropertyName("originalSize")] + public int OriginalSize { get; set; } + + [JsonPropertyName("lastUpd")] + public DateTime LastUpd { get; set; } + + [JsonPropertyName("descrizione")] + public string Descrizione { get; set; } + + [JsonPropertyName("modello")] + public string Modello { get; set; } +} \ No newline at end of file diff --git a/salesbook.Shared/Core/Dto/CRMCreateContactResponseDTO.cs b/salesbook.Shared/Core/Dto/CRMCreateContactResponseDTO.cs index bef2d9a..5d8b503 100644 --- a/salesbook.Shared/Core/Dto/CRMCreateContactResponseDTO.cs +++ b/salesbook.Shared/Core/Dto/CRMCreateContactResponseDTO.cs @@ -10,4 +10,10 @@ public class CRMCreateContactResponseDTO [JsonPropertyName("ptbPros")] public PtbPros? PtbPros { get; set; } + + [JsonPropertyName("vtbCliePersRif")] + public List VtbCliePersRif { get; set; } + + [JsonPropertyName("ptbProsRifs")] + public List PtbProsRif { get; set; } } \ No newline at end of file diff --git a/salesbook.Shared/Core/Dto/CRMTransferProspectRequestDTO.cs b/salesbook.Shared/Core/Dto/CRMTransferProspectRequestDTO.cs new file mode 100644 index 0000000..ce354cb --- /dev/null +++ b/salesbook.Shared/Core/Dto/CRMTransferProspectRequestDTO.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +namespace salesbook.Shared.Core.Dto; + +public class CRMTransferProspectRequestDTO +{ + [JsonPropertyName("codAnag")] + public string? CodAnag { get; set; } + + [JsonPropertyName("codPpro")] + public string? CodPpro { get; set; } +} \ No newline at end of file diff --git a/salesbook.Shared/Core/Dto/CRMTransferProspectResponseDTO.cs b/salesbook.Shared/Core/Dto/CRMTransferProspectResponseDTO.cs new file mode 100644 index 0000000..863124c --- /dev/null +++ b/salesbook.Shared/Core/Dto/CRMTransferProspectResponseDTO.cs @@ -0,0 +1,10 @@ +using salesbook.Shared.Core.Entity; +using System.Text.Json.Serialization; + +namespace salesbook.Shared.Core.Dto; + +public class CRMTransferProspectResponseDTO +{ + [JsonPropertyName("anagClie")] + public AnagClie? AnagClie { get; set; } +} \ No newline at end of file diff --git a/salesbook.Shared/Core/Entity/PtbProsRif.cs b/salesbook.Shared/Core/Entity/PtbProsRif.cs index da396df..0da81aa 100644 --- a/salesbook.Shared/Core/Entity/PtbProsRif.cs +++ b/salesbook.Shared/Core/Entity/PtbProsRif.cs @@ -6,11 +6,36 @@ namespace salesbook.Shared.Core.Entity; [Table("ptb_pros_rif")] public class PtbProsRif { + [PrimaryKey, Column("composite_key")] + public string CompositeKey { get; set; } + + private string? _codPpro; + [Column("cod_ppro"), JsonPropertyName("codPpro"), Indexed(Name = "PtbProsRifPK", Order = 1, Unique = true)] - public string CodPpro { get; set; } + public string? CodPpro + { + get => _codPpro; + set + { + _codPpro = value; + if (_codPpro != null && _idPersRif != null) + UpdateCompositeKey(); + } + } + + private int? _idPersRif; [Column("id_pers_rif"), JsonPropertyName("idPersRif"), Indexed(Name = "PtbProsRifPK", Order = 2, Unique = true)] - public int IdPersRif { get; set; } + public int? IdPersRif + { + get => _idPersRif; + set + { + _idPersRif = value; + if (_codPpro != null && _idPersRif != null) + UpdateCompositeKey(); + } + } [Column("persona_rif"), JsonPropertyName("personaRif")] public string PersonaRif { get; set; } @@ -29,4 +54,7 @@ public class PtbProsRif [Column("telefono"), JsonPropertyName("telefono")] public string Telefono { get; set; } + + private void UpdateCompositeKey() => + CompositeKey = $"{CodPpro}::{IdPersRif}"; } \ No newline at end of file diff --git a/salesbook.Shared/Core/Entity/StbActivity.cs b/salesbook.Shared/Core/Entity/StbActivity.cs index 25149e8..a92c247 100644 --- a/salesbook.Shared/Core/Entity/StbActivity.cs +++ b/salesbook.Shared/Core/Entity/StbActivity.cs @@ -7,7 +7,7 @@ namespace salesbook.Shared.Core.Entity; public class StbActivity { [PrimaryKey, Column("activity_id"), JsonPropertyName("activityId")] - public string ActivityId { get; set; } + public string? ActivityId { get; set; } [Column("activity_result_id"), JsonPropertyName("activityResultId")] public string? ActivityResultId { get; set; } diff --git a/salesbook.Shared/Core/Entity/StbActivityType.cs b/salesbook.Shared/Core/Entity/StbActivityType.cs index cc49041..53f02fd 100644 --- a/salesbook.Shared/Core/Entity/StbActivityType.cs +++ b/salesbook.Shared/Core/Entity/StbActivityType.cs @@ -6,11 +6,36 @@ namespace salesbook.Shared.Core.Entity; [Table("stb_activity_type")] public class StbActivityType { + [PrimaryKey, Column("composite_key")] + public string CompositeKey { get; set; } + + private string? _activityTypeId; + [Column("activity_type_id"), JsonPropertyName("activityTypeId"), Indexed(Name = "ActivityTypePK", Order = 1, Unique = true)] - public string ActivityTypeId { get; set; } + public string? ActivityTypeId + { + get => _activityTypeId; + set + { + _activityTypeId = value; + if (_activityTypeId != null && _flagTipologia != null) + UpdateCompositeKey(); + } + } + + private string? _flagTipologia; [Column("flag_tipologia"), JsonPropertyName("flagTipologia"), Indexed(Name = "ActivityTypePK", Order = 2, Unique = true)] - public string FlagTipologia { get; set; } + public string? FlagTipologia + { + get => _flagTipologia; + set + { + _flagTipologia = value; + if (_activityTypeId != null && _flagTipologia != null) + UpdateCompositeKey(); + } + } [Column("estimated_duration"), JsonPropertyName("estimatedDuration")] public double? EstimatedDuration { get; set; } = 0; @@ -38,4 +63,7 @@ public class StbActivityType [Column("flag_view_calendar"), JsonPropertyName("flagViewCalendar")] public bool FlagViewCalendar { get; set; } + + private void UpdateCompositeKey() => + CompositeKey = $"{ActivityTypeId}::{FlagTipologia}"; } \ No newline at end of file diff --git a/salesbook.Shared/Core/Entity/VtbCliePersRif.cs b/salesbook.Shared/Core/Entity/VtbCliePersRif.cs index 79a6e69..eab19c5 100644 --- a/salesbook.Shared/Core/Entity/VtbCliePersRif.cs +++ b/salesbook.Shared/Core/Entity/VtbCliePersRif.cs @@ -6,11 +6,36 @@ namespace salesbook.Shared.Core.Entity; [Table("vtb_clie_pers_rif")] public class VtbCliePersRif { + [PrimaryKey, Column("composite_key")] + public string CompositeKey { get; set; } + + private int? _idPersRif; + [Column("id_pers_rif"), JsonPropertyName("idPersRif"), Indexed(Name = "VtbCliePersRifPK", Order = 1, Unique = true)] - public int IdPersRif { get; set; } + public int? IdPersRif + { + get => _idPersRif; + set + { + _idPersRif = value; + if (_idPersRif != null && _codAnag != null) + UpdateCompositeKey(); + } + } + + private string? _codAnag; [Column("cod_anag"), JsonPropertyName("codAnag"), Indexed(Name = "VtbCliePersRifPK", Order = 2, Unique = true)] - public string CodAnag { get; set; } + public string? CodAnag + { + get => _codAnag; + set + { + _codAnag = value; + if (_idPersRif != null && _codAnag != null) + UpdateCompositeKey(); + } + } [Column("persona_rif"), JsonPropertyName("personaRif")] public string PersonaRif { get; set; } @@ -38,4 +63,7 @@ public class VtbCliePersRif [Column("data_ult_agg"), JsonPropertyName("dataUltAgg")] public DateTime? DataUltAgg { get; set; } = DateTime.Now; + + private void UpdateCompositeKey() => + CompositeKey = $"{IdPersRif}::{CodAnag}"; } \ No newline at end of file diff --git a/salesbook.Shared/Core/Entity/VtbDest.cs b/salesbook.Shared/Core/Entity/VtbDest.cs index db9d273..c125a1e 100644 --- a/salesbook.Shared/Core/Entity/VtbDest.cs +++ b/salesbook.Shared/Core/Entity/VtbDest.cs @@ -6,11 +6,36 @@ namespace salesbook.Shared.Core.Entity; [Table("vtb_dest")] public class VtbDest { + [PrimaryKey, Column("composite_key")] + public string CompositeKey { get; set; } + + private string? _codAnag; + [Column("cod_anag"), JsonPropertyName("codAnag"), Indexed(Name = "VtbDestPK", Order = 1, Unique = true)] - public string CodAnag { get; set; } + public string? CodAnag + { + get => _codAnag; + set + { + _codAnag = value; + if (_codAnag != null && _codVdes != null) + UpdateCompositeKey(); + } + } + + private string? _codVdes; [Column("cod_vdes"), JsonPropertyName("codVdes"), Indexed(Name = "VtbDestPK", Order = 2, Unique = true)] - public string CodVdes { get; set; } + public string? CodVdes + { + get => _codVdes; + set + { + _codVdes = value; + if (_codAnag != null && _codVdes != null) + UpdateCompositeKey(); + } + } [Column("destinatario"), JsonPropertyName("destinatario")] public string Destinatario { get; set; } @@ -194,4 +219,7 @@ public class VtbDest [Column("cod_fisc_legale"), JsonPropertyName("codFiscLegale")] public string CodFiscLegale { get; set; } + + private void UpdateCompositeKey() => + CompositeKey = $"{CodAnag}::{CodVdes}"; } \ No newline at end of file diff --git a/salesbook.Shared/Core/Interface/IIntegryApiService.cs b/salesbook.Shared/Core/Interface/IIntegryApiService.cs index 8b2f02b..3635223 100644 --- a/salesbook.Shared/Core/Interface/IIntegryApiService.cs +++ b/salesbook.Shared/Core/Interface/IIntegryApiService.cs @@ -16,9 +16,12 @@ public interface IIntegryApiService Task?> SaveActivity(ActivityDTO activity); Task SaveContact(CRMCreateContactRequestDTO request); Task CheckVat(CheckVatRequestDTO request); + Task TransferProspect(CRMTransferProspectRequestDTO request); Task UploadFile(string id, byte[] file, string fileName); - + Task> GetActivityFile(string activityId); + Task DownloadFile(string activityId, string fileName); + //Position Task SavePosition(PositionDTO position); Task RetrievePosition(string id); diff --git a/salesbook.Shared/Core/Interface/IManageDataService.cs b/salesbook.Shared/Core/Interface/IManageDataService.cs index 42d0dfb..0729793 100644 --- a/salesbook.Shared/Core/Interface/IManageDataService.cs +++ b/salesbook.Shared/Core/Interface/IManageDataService.cs @@ -13,6 +13,7 @@ public interface IManageDataService Task GetSpecificContact(string codAnag, bool IsContact); Task InsertOrUpdate(T objectToSave); + Task InsertOrUpdate(List listToSave); Task Delete(T objectToDelete); Task DeleteActivity(ActivityDTO activity); diff --git a/salesbook.Shared/Core/Services/IntegryApiService.cs b/salesbook.Shared/Core/Services/IntegryApiService.cs index f1b5489..5cc6714 100644 --- a/salesbook.Shared/Core/Services/IntegryApiService.cs +++ b/salesbook.Shared/Core/Services/IntegryApiService.cs @@ -72,6 +72,9 @@ public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUser public Task SaveContact(CRMCreateContactRequestDTO request) => integryApiRestClient.AuthorizedPost("crm/createContact", request); + public Task TransferProspect(CRMTransferProspectRequestDTO request) => + integryApiRestClient.AuthorizedPost("crm/transferProspect", request)!; + public Task CheckVat(CheckVatRequestDTO request) => integryApiRestClient.Post("checkPartitaIva", request)!; @@ -113,7 +116,7 @@ public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUser { var queryParams = new Dictionary { { "activityId", activityId } }; - using var content = new MultipartFormDataContent(); + var content = new MultipartFormDataContent(); var fileContent = new ByteArrayContent(file); fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data"); content.Add(fileContent, "files", fileName); @@ -121,6 +124,19 @@ public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUser return integryApiRestClient.Post($"uploadStbActivityFileAttachment", content, queryParams); } + public Task> GetActivityFile(string activityId) + { + var queryParams = new Dictionary + { + { "activityId", activityId } + }; + + return integryApiRestClient.AuthorizedGet>($"activity/getActivityFile", queryParams)!; + } + + public Task DownloadFile(string activityId, string fileName) => + integryApiRestClient.Download($"downloadStbFileAttachment/{activityId}/{fileName}")!; + public Task SavePosition(PositionDTO position) => integryApiRestClient.Post("savePosition", position)!; diff --git a/salesbook.Web/Core/Services/ManageDataService.cs b/salesbook.Web/Core/Services/ManageDataService.cs index 3061e78..3775113 100644 --- a/salesbook.Web/Core/Services/ManageDataService.cs +++ b/salesbook.Web/Core/Services/ManageDataService.cs @@ -32,6 +32,11 @@ public class ManageDataService : IManageDataService throw new NotImplementedException(); } + public Task InsertOrUpdate(List listToSave) + { + throw new NotImplementedException(); + } + public Task Delete(T objectToDelete) { throw new NotImplementedException();