diff --git a/salesbook.Maui/Core/Services/ManageDataService.cs b/salesbook.Maui/Core/Services/ManageDataService.cs index 75e325d..e8ac95d 100644 --- a/salesbook.Maui/Core/Services/ManageDataService.cs +++ b/salesbook.Maui/Core/Services/ManageDataService.cs @@ -309,19 +309,28 @@ public class ManageDataService( { return Task.Run(async () => { - if (response.AnagClie != null) + try { - await localDb.InsertOrUpdate(response.AnagClie); + if (response.AnagClie != null) + { + await localDb.InsertOrUpdate(response.AnagClie); - if (response.VtbDest != null) await localDb.InsertOrUpdate(response.VtbDest); - if (response.VtbCliePersRif != null) await localDb.InsertOrUpdate(response.VtbCliePersRif); + if (response.VtbDest != null) await localDb.InsertOrUpdate(response.VtbDest); + if (response.VtbCliePersRif != null) await localDb.InsertOrUpdate(response.VtbCliePersRif); + } + + if (response.PtbPros != null) + { + await localDb.InsertOrUpdate(response.PtbPros); + + if (response.PtbProsRif != null) await localDb.InsertOrUpdate(response.PtbProsRif); + } } - - if (response.PtbPros != null) + catch (Exception e) { - await localDb.InsertOrUpdate(response.PtbPros); - - if (response.PtbProsRif != null) await localDb.InsertOrUpdate(response.PtbProsRif); + Console.WriteLine(e.Message); + SentrySdk.CaptureException(e); + throw; } }); } diff --git a/salesbook.Shared/Components/Pages/User.razor b/salesbook.Shared/Components/Pages/User.razor index a312a2e..e42f70b 100644 --- a/salesbook.Shared/Components/Pages/User.razor +++ b/salesbook.Shared/Components/Pages/User.razor @@ -425,7 +425,7 @@ else set { _filteredActivity = value; - StateHasChanged(); + InvokeAsync(StateHasChanged); } } diff --git a/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor b/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor index 91e5bee..1b33a17 100644 --- a/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor +++ b/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor @@ -41,7 +41,7 @@ @if (ActivityModel.CodJcom != null && SelectedComessa == null) { - + } else { @@ -100,7 +100,7 @@ @if (ActivityModel.UserName != null && SelectedUser == null) { - + } else { @@ -128,7 +128,7 @@ @if (ActivityType.IsNullOrEmpty()) { - + } else { @@ -400,7 +400,25 @@ 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" }); diff --git a/salesbook.Shared/Components/SingleElements/Modal/AddAttached.razor b/salesbook.Shared/Components/SingleElements/Modal/AddAttached.razor index ca68c9a..f67722d 100644 --- a/salesbook.Shared/Components/SingleElements/Modal/AddAttached.razor +++ b/salesbook.Shared/Components/SingleElements/Modal/AddAttached.razor @@ -151,28 +151,31 @@ private void OnNewName() { - switch (Attached.Type) + if (Attached != null) { - case AttachedDTO.TypeAttached.Position: + switch (Attached.Type) { - CanAddPosition = false; + case AttachedDTO.TypeAttached.Position: + { + CanAddPosition = false; - Attached.Description = NewName!; + Attached.Description = NewName!; Attached.Name = NewName!; - break; - } - case AttachedDTO.TypeAttached.Image: - { - var extension = Path.GetExtension(Attached.Name); - Attached.Name = NewName! + extension; + break; + } + case AttachedDTO.TypeAttached.Image: + { + var extension = Path.GetExtension(Attached.Name); + Attached.Name = NewName! + extension; - break; + break; + } + case AttachedDTO.TypeAttached.Document: + break; + default: + throw new ArgumentOutOfRangeException(); } - case AttachedDTO.TypeAttached.Document: - break; - default: - throw new ArgumentOutOfRangeException(); } MudDialog.Close(Attached); diff --git a/salesbook.Shared/Core/Entity/PtbProsRif.cs b/salesbook.Shared/Core/Entity/PtbProsRif.cs index 0da81aa..4108bb9 100644 --- a/salesbook.Shared/Core/Entity/PtbProsRif.cs +++ b/salesbook.Shared/Core/Entity/PtbProsRif.cs @@ -7,7 +7,7 @@ namespace salesbook.Shared.Core.Entity; public class PtbProsRif { [PrimaryKey, Column("composite_key")] - public string CompositeKey { get; set; } + public string CompositeKey { get; set; } = null!; private string? _codPpro; diff --git a/salesbook.Shared/Core/Entity/StbActivity.cs b/salesbook.Shared/Core/Entity/StbActivity.cs index a92c247..0cec552 100644 --- a/salesbook.Shared/Core/Entity/StbActivity.cs +++ b/salesbook.Shared/Core/Entity/StbActivity.cs @@ -173,4 +173,7 @@ public class StbActivity [Column("plan_id"), JsonPropertyName("planId")] public long? PlanId { get; set; } + + [Column("id_posizione"), JsonPropertyName("idPosizione")] + public long? IdPosizione { get; set; } } \ No newline at end of file diff --git a/salesbook.Shared/Core/Interface/IntegryApi/IIntegryApiService.cs b/salesbook.Shared/Core/Interface/IntegryApi/IIntegryApiService.cs index 1cd51af..4ab03a5 100644 --- a/salesbook.Shared/Core/Interface/IntegryApi/IIntegryApiService.cs +++ b/salesbook.Shared/Core/Interface/IntegryApi/IIntegryApiService.cs @@ -33,7 +33,7 @@ public interface IIntegryApiService //Position Task SavePosition(PositionDTO position); - Task RetrievePosition(string id); + Task RetrievePosition(long id); //Google Task?> Geocode(string address); diff --git a/salesbook.Shared/Core/Services/IntegryApiService.cs b/salesbook.Shared/Core/Services/IntegryApiService.cs index 8c603d0..8519862 100644 --- a/salesbook.Shared/Core/Services/IntegryApiService.cs +++ b/salesbook.Shared/Core/Services/IntegryApiService.cs @@ -164,7 +164,7 @@ public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUser public Task SavePosition(PositionDTO position) => integryApiRestClient.Post("savePosition", position)!; - public Task RetrievePosition(string id) + public Task RetrievePosition(long id) { var queryParams = new Dictionary { { "id", id } };