diff --git a/salesbook.Maui/Core/Services/ManageDataService.cs b/salesbook.Maui/Core/Services/ManageDataService.cs index c6dd0ae..087b65a 100644 --- a/salesbook.Maui/Core/Services/ManageDataService.cs +++ b/salesbook.Maui/Core/Services/ManageDataService.cs @@ -232,7 +232,7 @@ public class ManageDataService( return await MapActivity(activities); } - private async Task> MapActivity(List? activities) + public async Task> MapActivity(List? activities) { if (activities == null) return []; @@ -291,7 +291,7 @@ public class ManageDataService( } } - dto.Commessa = jtbComtList.LastOrDefault(); + dto.Commessa = jtbComtList.Find(x => x.CodJcom.Equals(dto.CodJcom)); return dto; }) .ToList(); diff --git a/salesbook.Shared/Components/Pages/Commessa.razor b/salesbook.Shared/Components/Pages/Commessa.razor index f307970..b2dfc03 100644 --- a/salesbook.Shared/Components/Pages/Commessa.razor +++ b/salesbook.Shared/Components/Pages/Commessa.razor @@ -149,10 +149,9 @@ else await Task.Run(async () => { var activities = await IntegryApiService.RetrieveActivity(new CRMRetrieveActivityRequestDTO { CodJcom = CodJcom }); - ActivityList = Mapper.Map>(activities) - .OrderBy(x => - (x.EffectiveTime ?? x.EstimatedTime) ?? x.DataInsAct - ).ToList(); + ActivityList = (await ManageData.MapActivity(activities)).OrderByDescending(x => + (x.EffectiveTime ?? x.EstimatedTime) ?? x.DataInsAct + ).ToList(); }); ActivityIsLoading = false; diff --git a/salesbook.Shared/Components/Pages/User.razor b/salesbook.Shared/Components/Pages/User.razor index 65e8b87..94e8b52 100644 --- a/salesbook.Shared/Components/Pages/User.razor +++ b/salesbook.Shared/Components/Pages/User.razor @@ -24,11 +24,11 @@ Back="true" BackOnTop="true" Title="" - ShowProfile="false" /> + ShowProfile="false"/> @if (IsLoading) { - + } else { @@ -123,7 +123,7 @@ else
@foreach (var person in PersRif) { - + @if (person != PersRif.Last()) {
@@ -147,11 +147,11 @@ else
@if (IsLoadingCommesse) { - + } else if (Commesse?.Count == 0) { - + } else if (Commesse != null) { @@ -162,13 +162,13 @@ else Variant="Variant.Text" @bind-Value="SearchTermCommesse" OnDebounceIntervalElapsed="() => ApplyFiltersCommesse()" - DebounceInterval="500" /> + DebounceInterval="500"/>
@if (IsLoadingSteps) { - + } @foreach (var commessa in CurrentPageCommesse) @@ -176,14 +176,14 @@ else
@if (Steps.TryGetValue(commessa.CodJcom, out var steps)) { - + } else { - + @if (IsLoadingStep(commessa.CodJcom)) { - + } }
@@ -194,7 +194,7 @@ else
+ Color="Color.Primary"/>
@@ -217,11 +217,11 @@ else
@if (ActivityIsLoading) { - + } else if (ActivityList?.Count == 0) { - + } else if (ActivityList != null) { @@ -232,13 +232,13 @@ else Variant="Variant.Text" @bind-Value="SearchTermActivity" OnDebounceIntervalElapsed="() => ApplyFiltersActivity()" - DebounceInterval="500" /> + DebounceInterval="500"/>
@foreach (var activity in CurrentPageActivity) { - + } @if (TotalPagesActivity > 1) @@ -246,7 +246,7 @@ else
+ Color="Color.Primary"/>
@@ -265,9 +265,9 @@ else }
- + - +
} @@ -527,10 +527,9 @@ else await Task.Run(async () => { var activities = await IntegryApiService.RetrieveActivity(new CRMRetrieveActivityRequestDTO { CodAnag = Anag.CodContact }); - ActivityList = Mapper.Map>(activities) - .OrderByDescending(x => - (x.EffectiveTime ?? x.EstimatedTime) ?? x.DataInsAct - ).ToList(); + ActivityList = (await ManageData.MapActivity(activities)).OrderByDescending(x => + (x.EffectiveTime ?? x.EstimatedTime) ?? x.DataInsAct + ).ToList(); }); UserState.Activitys = ActivityList; @@ -794,4 +793,5 @@ else } #endregion + } \ No newline at end of file diff --git a/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor b/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor index e2b13b7..91e5bee 100644 --- a/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor +++ b/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor @@ -39,18 +39,26 @@
Commessa - + @if (ActivityModel.CodJcom != null && SelectedComessa == null) + { + + } + else + { + + }
@@ -90,19 +98,27 @@
Assegnata a - + @if (ActivityModel.UserName != null && SelectedUser == null) + { + + } + else + { + + }
@@ -110,12 +126,19 @@
Tipo - - @foreach (var type in ActivityType) - { - @type.ActivityTypeId - } - + @if (ActivityType.IsNullOrEmpty()) + { + + } + else + { + + @foreach (var type in ActivityType) + { + @type.ActivityTypeId + } + + }
@@ -370,14 +393,14 @@ { return Task.Run(async () => { - if (!IsNew && Id != null) - ActivityFileList = await IntegryApiService.GetActivityFile(Id); + SelectedComessa = ActivityModel.Commessa; Users = await ManageData.GetTable(); if (!ActivityModel.UserName.IsNullOrEmpty()) SelectedUser = Users.FindLast(x => x.UserName.Equals(ActivityModel.UserName)); - SelectedComessa = ActivityModel.Commessa; + if (!IsNew && Id != null) + ActivityFileList = await IntegryApiService.GetActivityFile(Id); ActivityResult = await ManageData.GetTable(); Clienti = await ManageData.GetClienti(new WhereCondContact { FlagStato = "A" }); @@ -510,6 +533,20 @@ OnAfterChangeValue(); } + private async Task OnCommessaClear() + { + ActivityModel.Commessa = null; + ActivityModel.CodJcom = null; + StateHasChanged(); + } + + private async Task OnUserClear() + { + ActivityModel.UserName = null; + ActivityType = []; + StateHasChanged(); + } + private void OnAfterChangeTimeBefore() { if (ActivityModel.EstimatedTime is not null) diff --git a/salesbook.Shared/Core/Interface/IManageDataService.cs b/salesbook.Shared/Core/Interface/IManageDataService.cs index 993e083..2fbcf4d 100644 --- a/salesbook.Shared/Core/Interface/IManageDataService.cs +++ b/salesbook.Shared/Core/Interface/IManageDataService.cs @@ -25,5 +25,7 @@ public interface IManageDataService Task Delete(T objectToDelete); Task DeleteActivity(ActivityDTO activity); + Task> MapActivity(List? activities); + Task ClearDb(); } \ No newline at end of file