diff --git a/src/PostIt/PostIt.Tests/ActivitiesPageViewModelTests.cs b/src/PostIt/PostIt.Tests/ActivitiesPageViewModelTests.cs index c2fab4c3..3f602fc4 100644 --- a/src/PostIt/PostIt.Tests/ActivitiesPageViewModelTests.cs +++ b/src/PostIt/PostIt.Tests/ActivitiesPageViewModelTests.cs @@ -72,9 +72,9 @@ public class ActivitiesPageViewModelTests { Paths.Add(path); - if (typeof(T) == typeof(List)) + if (typeof(T) == typeof(List)) { - var activities = new List + var activities = new List { new() { @@ -82,11 +82,11 @@ public class ActivitiesPageViewModelTests Name = "Brush", Description = "Coiffure à domicile", PerformerCount = 1, - Forms = new List + Forms = new List { new() { Id = 1, ActionName = "Rdv", Title = "Rendez-vous" } }, - Children = new List + Children = new List { new() { @@ -95,7 +95,7 @@ public class ActivitiesPageViewModelTests Description = "Spécialisation premium", ParentCode = "brush", PerformerCount = 1, - Forms = new List + Forms = new List { new() { Id = 2, ActionName = "Rdv", Title = "Rendez-vous premium" } } @@ -106,14 +106,14 @@ public class ActivitiesPageViewModelTests return Task.FromResult((T)(object)activities); } - if (typeof(T) == typeof(List)) + if (typeof(T) == typeof(List)) { var performers = path.EndsWith("brush-pro/users", StringComparison.Ordinal) - ? new List + ? new List { new() { PerformerId = "pro-2", HasPerformerProfile = true, Active = false, UserName = "Bob", ActivityCode = "brush-pro", ActivityName = "Brush Pro", ExtraActivityCount = 2 } } - : new List + : new List { new() { PerformerId = "pro-1", HasPerformerProfile = true, Active = true, UserName = "Alice", ActivityCode = "brush", ActivityName = "Brush", ExtraActivityCount = 0 } }; diff --git a/src/PostIt/PostIt.Tests/BillingCommandPageViewModelTests.cs b/src/PostIt/PostIt.Tests/BillingCommandPageViewModelTests.cs index d80d3195..5b6f51bf 100644 --- a/src/PostIt/PostIt.Tests/BillingCommandPageViewModelTests.cs +++ b/src/PostIt/PostIt.Tests/BillingCommandPageViewModelTests.cs @@ -17,9 +17,9 @@ public class BillingCommandPageViewModelTests var api = new RecordingApi(); var client = new BillingApiClient(api, "https://business.example/api/v1/"); var vm = new BillingCommandPageViewModel( - new ActivityBrowseItemDto { Code = "dev", Name = "Développement" }, + new ActivityInfo { Code = "dev", Name = "Développement" }, new ActivityUserDisplayItem { PerformerId = "perf-1", UserName = "Alice" }, - new CommandFormSummaryDto { Id = 12, ActionName = "Rdv", Title = "Rendez-vous" }, + new CommandFormSummary { Id = 12, ActionName = "Rdv", Title = "Rendez-vous" }, client) { EventDateText = "2026-09-02 14:30", @@ -48,9 +48,9 @@ public class BillingCommandPageViewModelTests var api = new RecordingApi(); var client = new BillingApiClient(api, "https://business.example/api/v1/"); var vm = new BillingCommandPageViewModel( - new ActivityBrowseItemDto { Code = "book", Name = "Book" }, + new ActivityInfo { Code = "book", Name = "Book" }, new ActivityUserDisplayItem { PerformerId = "perf-2", UserName = "Bob" }, - new CommandFormSummaryDto { Id = 13, ActionName = "Book", Title = "Réservation" }, + new CommandFormSummary { Id = 13, ActionName = "Book", Title = "Réservation" }, client); await vm.SubmitCommand.ExecuteAsync(null); @@ -65,9 +65,9 @@ public class BillingCommandPageViewModelTests var api = new RecordingApi(); var client = new BillingApiClient(api, "https://business.example/api/v1/"); var vm = new BillingCommandPageViewModel( - new ActivityBrowseItemDto { Code = "dev", Name = "Développement" }, + new ActivityInfo { Code = "dev", Name = "Développement" }, new ActivityUserDisplayItem { PerformerId = "perf-1", UserName = "Alice" }, - new CommandFormSummaryDto { Id = 12, ActionName = "Rdv", Title = "Rendez-vous" }, + new CommandFormSummary { Id = 12, ActionName = "Rdv", Title = "Rendez-vous" }, client) { EventDateText = "2026-09-02 14:30", @@ -98,9 +98,9 @@ public class BillingCommandPageViewModelTests var api = new RecordingApi(); var client = new BillingApiClient(api, "https://business.example/api/v1/"); var vm = new BillingCommandPageViewModel( - new ActivityBrowseItemDto { Code = "dev", Name = "Développement" }, + new ActivityInfo { Code = "dev", Name = "Développement" }, new ActivityUserDisplayItem { PerformerId = "perf-1", UserName = "Alice" }, - new CommandFormSummaryDto { Id = 12, ActionName = "Rdv", Title = "Rendez-vous" }, + new CommandFormSummary { Id = 12, ActionName = "Rdv", Title = "Rendez-vous" }, client); await vm.UseCurrentLocationCommand.ExecuteAsync(null); @@ -127,9 +127,9 @@ public class BillingCommandPageViewModelTests }; var client = new BillingApiClient(api, "https://business.example/api/v1/"); var vm = new BillingCommandPageViewModel( - new ActivityBrowseItemDto { Code = "brush", Name = "Brush" }, + new ActivityInfo { Code = "brush", Name = "Brush" }, new ActivityUserDisplayItem { PerformerId = "perf-2", UserName = "Bob" }, - new CommandFormSummaryDto { Id = 13, ActionName = "Brush", Title = "Coupe" }, + new CommandFormSummary { Id = 13, ActionName = "Brush", Title = "Coupe" }, client) { EventDateText = "2026-09-02 14:30", @@ -163,9 +163,9 @@ public class BillingCommandPageViewModelTests }; var client = new BillingApiClient(api, "https://business.example/api/v1/"); var vm = new BillingCommandPageViewModel( - new ActivityBrowseItemDto { Code = "mbrush", Name = "MBrush" }, + new ActivityInfo { Code = "mbrush", Name = "MBrush" }, new ActivityUserDisplayItem { PerformerId = "perf-3", UserName = "Cara" }, - new CommandFormSummaryDto { Id = 14, ActionName = "MBrush", Title = "Coupe groupée" }, + new CommandFormSummary { Id = 14, ActionName = "MBrush", Title = "Coupe groupée" }, client) { EventDateText = "2026-09-03 10:00", @@ -201,9 +201,9 @@ public class BillingCommandPageViewModelTests }; var client = new BillingApiClient(api, "https://business.example/api/v1/"); var vm = new BillingCommandPageViewModel( - new ActivityBrowseItemDto { Code = "brush", Name = "Brush" }, + new ActivityInfo { Code = "brush", Name = "Brush" }, new ActivityUserDisplayItem { PerformerId = "perf-2", UserName = "Bob" }, - new CommandFormSummaryDto { Id = 13, ActionName = "Brush", Title = "Coupe" }, + new CommandFormSummary { Id = 13, ActionName = "Brush", Title = "Coupe" }, client); await vm.InitializeAsync(new BillingQueryDetailsDto diff --git a/src/PostIt/PostIt.Tests/BillingQueriesPageViewModelTests.cs b/src/PostIt/PostIt.Tests/BillingQueriesPageViewModelTests.cs index a5d37532..a7f2b084 100644 --- a/src/PostIt/PostIt.Tests/BillingQueriesPageViewModelTests.cs +++ b/src/PostIt/PostIt.Tests/BillingQueriesPageViewModelTests.cs @@ -14,9 +14,9 @@ public class BillingQueriesPageViewModelTests var api = new StubBillingApi(); var client = new BillingApiClient(api, "https://business.example/api/v1/"); var vm = new BillingQueriesPageViewModel( - new ActivityBrowseItemDto { Code = "dev", Name = "Développement" }, + new ActivityInfo { Code = "dev", Name = "Développement" }, new ActivityUserDisplayItem { PerformerId = "perf-1", UserName = "Alice" }, - new CommandFormSummaryDto { Id = 1, ActionName = "Rdv", Title = "Rendez-vous" }, + new CommandFormSummary { Id = 1, ActionName = "Rdv", Title = "Rendez-vous" }, client); await vm.InitializeAsync(); @@ -33,9 +33,9 @@ public class BillingQueriesPageViewModelTests var api = new StubBillingApi(); var client = new BillingApiClient(api, "https://business.example/api/v1/"); var vm = new BillingQueriesPageViewModel( - new ActivityBrowseItemDto { Code = "dev", Name = "Développement" }, + new ActivityInfo { Code = "dev", Name = "Développement" }, new ActivityUserDisplayItem { PerformerId = "perf-1", UserName = "Alice" }, - new CommandFormSummaryDto { Id = 1, ActionName = "Rdv", Title = "Rendez-vous" }, + new CommandFormSummary { Id = 1, ActionName = "Rdv", Title = "Rendez-vous" }, client, isReadOnly: true, ongoingOnly: true); @@ -131,4 +131,4 @@ public class BillingQueriesPageViewModelTests public ValueTask DisposeAsync() => ValueTask.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/PostIt/PostIt/ViewModels/ActivitiesPageViewModel.cs b/src/PostIt/PostIt/ViewModels/ActivitiesPageViewModel.cs index 5268d07a..2c776d16 100644 --- a/src/PostIt/PostIt/ViewModels/ActivitiesPageViewModel.cs +++ b/src/PostIt/PostIt/ViewModels/ActivitiesPageViewModel.cs @@ -20,16 +20,16 @@ public partial class ActivitiesPageViewModel : ViewModelBase private bool _syncingSelection; [ObservableProperty] - public partial ObservableCollection Activities { get; set; } = new(); + public partial ObservableCollection Activities { get; set; } = new(); [ObservableProperty] - public partial ActivityBrowseItemDto? SelectedActivity { get; set; } + public partial ActivityInfo? SelectedActivity { get; set; } [ObservableProperty] - public partial ObservableCollection Specializations { get; set; } = new(); + public partial ObservableCollection Specializations { get; set; } = new(); [ObservableProperty] - public partial ActivityBrowseItemDto? SelectedSpecialization { get; set; } + public partial ActivityInfo? SelectedSpecialization { get; set; } [ObservableProperty] public partial ObservableCollection Performers { get; set; } = new(); @@ -43,7 +43,7 @@ public partial class ActivitiesPageViewModel : ViewModelBase [ObservableProperty] public partial string StatusMessage { get; set; } = "Choisissez une activité."; - public ActivityBrowseItemDto? CurrentActivity => SelectedSpecialization ?? SelectedActivity; + public ActivityInfo? CurrentActivity => SelectedSpecialization ?? SelectedActivity; public string SelectedActivityLabel => SelectedActivity?.Name ?? "(aucune activité)"; public string CurrentActivityLabel => CurrentActivity?.Name ?? "(aucune)"; public int CurrentFormCount => CurrentActivity?.Forms?.Count ?? 0; @@ -66,19 +66,19 @@ public partial class ActivitiesPageViewModel : ViewModelBase _billingClient = billingClient ?? throw new ArgumentNullException(nameof(billingClient)); } - partial void OnSelectedActivityChanged(ActivityBrowseItemDto? value) + partial void OnSelectedActivityChanged(ActivityInfo? value) { if (_syncingSelection) return; _ = ShowActivitySafeAsync(value); } - partial void OnSelectedSpecializationChanged(ActivityBrowseItemDto? value) + partial void OnSelectedSpecializationChanged(ActivityInfo? value) { if (_syncingSelection) return; _ = ShowSpecializationSafeAsync(value); } - private async Task ShowActivitySafeAsync(ActivityBrowseItemDto? value) + private async Task ShowActivitySafeAsync(ActivityInfo? value) { try { @@ -94,7 +94,7 @@ public partial class ActivitiesPageViewModel : ViewModelBase } } - private async Task ShowSpecializationSafeAsync(ActivityBrowseItemDto? value) + private async Task ShowSpecializationSafeAsync(ActivityInfo? value) { try { @@ -117,7 +117,7 @@ public partial class ActivitiesPageViewModel : ViewModelBase try { var list = await _client.GetCatalogAsync(); - Activities = new ObservableCollection(list ?? new()); + Activities = new ObservableCollection(list ?? new()); var first = Activities.FirstOrDefault(); await ShowActivityAsync(first); @@ -128,15 +128,15 @@ public partial class ActivitiesPageViewModel : ViewModelBase } catch (HttpRequestException ex) when (ex.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden) { - Activities = new ObservableCollection(); - Specializations = new ObservableCollection(); + Activities = new ObservableCollection(); + Specializations = new ObservableCollection(); Performers = new ObservableCollection(); StatusMessage = "Accès refusé pour les activités (scope 'api'). Déconnectez puis reconnectez-vous."; } catch (Exception ex) { - Activities = new ObservableCollection(); - Specializations = new ObservableCollection(); + Activities = new ObservableCollection(); + Specializations = new ObservableCollection(); Performers = new ObservableCollection(); StatusMessage = $"Erreur: {ex.Message}"; } @@ -146,7 +146,7 @@ public partial class ActivitiesPageViewModel : ViewModelBase } } - public async Task ShowActivityAsync(ActivityBrowseItemDto? activity) + public async Task ShowActivityAsync(ActivityInfo? activity) { _syncingSelection = true; try @@ -163,7 +163,7 @@ public partial class ActivitiesPageViewModel : ViewModelBase OnPropertyChanged(nameof(SelectedActivityLabel)); OnPropertyChanged(nameof(CurrentActivityLabel)); OnPropertyChanged(nameof(CurrentFormCount)); - Specializations = new ObservableCollection(activity?.Children ?? new()); + Specializations = new ObservableCollection(activity?.Children ?? new()); if (activity is null) { @@ -175,7 +175,7 @@ public partial class ActivitiesPageViewModel : ViewModelBase await LoadPerformersAsync(activity); } - public async Task ShowSpecializationAsync(ActivityBrowseItemDto? specialization) + public async Task ShowSpecializationAsync(ActivityInfo? specialization) { _syncingSelection = true; try @@ -203,7 +203,7 @@ public partial class ActivitiesPageViewModel : ViewModelBase await LoadPerformersAsync(specialization); } - private async Task LoadPerformersAsync(ActivityBrowseItemDto activity) + private async Task LoadPerformersAsync(ActivityInfo activity) { IsBusy = true; try diff --git a/src/PostIt/PostIt/ViewModels/ActivityUserDisplayItem.cs b/src/PostIt/PostIt/ViewModels/ActivityUserDisplayItem.cs index ee06b883..3e4426b4 100644 --- a/src/PostIt/PostIt/ViewModels/ActivityUserDisplayItem.cs +++ b/src/PostIt/PostIt/ViewModels/ActivityUserDisplayItem.cs @@ -17,7 +17,7 @@ public sealed class ActivityUserDisplayItem public int ExtraActivityCount { get; init; } public string ExtraActivityLabel { get; init; } = "Pas d'autre activité"; - public static ActivityUserDisplayItem FromDto(ActivityPerformerDto dto) + public static ActivityUserDisplayItem FromDto(PerformerActivity dto) { return new ActivityUserDisplayItem { diff --git a/src/PostIt/PostIt/ViewModels/BillingCommandPageViewModel.cs b/src/PostIt/PostIt/ViewModels/BillingCommandPageViewModel.cs index 2ffeec26..cfd23086 100644 --- a/src/PostIt/PostIt/ViewModels/BillingCommandPageViewModel.cs +++ b/src/PostIt/PostIt/ViewModels/BillingCommandPageViewModel.cs @@ -21,9 +21,9 @@ public partial class BillingCommandPageViewModel : ViewModelBase { private readonly BillingApiClient _billingClient; - public ActivityBrowseItemDto Activity { get; } + public ActivityInfo Activity { get; } public ActivityUserDisplayItem Performer { get; } - public CommandFormSummaryDto Form { get; } + public CommandFormSummary Form { get; } [ObservableProperty] public partial bool IsBusy { get; set; } @@ -104,9 +104,9 @@ public partial class BillingCommandPageViewModel : ViewModelBase } public BillingCommandPageViewModel( - ActivityBrowseItemDto activity, + ActivityInfo activity, ActivityUserDisplayItem performer, - CommandFormSummaryDto form, + CommandFormSummary form, BillingApiClient billingClient) { Activity = activity ?? throw new ArgumentNullException(nameof(activity)); @@ -487,4 +487,4 @@ public partial class BillingCommandPageViewModel : ViewModelBase longitude = parsedLongitude; return true; } -} \ No newline at end of file +} diff --git a/src/PostIt/PostIt/ViewModels/BillingQueriesPageViewModel.cs b/src/PostIt/PostIt/ViewModels/BillingQueriesPageViewModel.cs index d680ba74..2504799f 100644 --- a/src/PostIt/PostIt/ViewModels/BillingQueriesPageViewModel.cs +++ b/src/PostIt/PostIt/ViewModels/BillingQueriesPageViewModel.cs @@ -18,9 +18,9 @@ public partial class BillingQueriesPageViewModel : ViewModelBase { private readonly BillingApiClient _billingClient; - public ActivityBrowseItemDto Activity { get; } + public ActivityInfo Activity { get; } public ActivityUserDisplayItem Performer { get; } - public CommandFormSummaryDto Form { get; } + public CommandFormSummary Form { get; } public bool IsReadOnly { get; } public bool OngoingOnly { get; } @@ -55,9 +55,9 @@ public partial class BillingQueriesPageViewModel : ViewModelBase } public BillingQueriesPageViewModel( - ActivityBrowseItemDto activity, + ActivityInfo activity, ActivityUserDisplayItem performer, - CommandFormSummaryDto form, + CommandFormSummary form, BillingApiClient billingClient, bool isReadOnly = false, bool ongoingOnly = false) @@ -170,4 +170,4 @@ public partial class BillingQueriesPageViewModel : ViewModelBase private static bool IsOngoingStatus(QueryStatus status) => status is QueryStatus.Inserted or QueryStatus.Accepted or QueryStatus.InProgress; -} \ No newline at end of file +} diff --git a/src/PostIt/PostIt/ViewModels/CommandFormsPageViewModel.cs b/src/PostIt/PostIt/ViewModels/CommandFormsPageViewModel.cs index e1453c11..e1ced1ef 100644 --- a/src/PostIt/PostIt/ViewModels/CommandFormsPageViewModel.cs +++ b/src/PostIt/PostIt/ViewModels/CommandFormsPageViewModel.cs @@ -15,14 +15,14 @@ public partial class CommandFormsPageViewModel : ViewModelBase { private readonly BillingApiClient _billingClient; - public ActivityBrowseItemDto Activity { get; } + public ActivityInfo Activity { get; } public ActivityUserDisplayItem Performer { get; } [ObservableProperty] - public partial ObservableCollection Forms { get; set; } + public partial ObservableCollection Forms { get; set; } [ObservableProperty, NotifyCanExecuteChangedFor(nameof(OpenSelectedFormCommand)), NotifyCanExecuteChangedFor(nameof(OpenQueriesCommand)), NotifyCanExecuteChangedFor(nameof(OpenOngoingQueriesCommand))] - public partial CommandFormSummaryDto? SelectedForm { get; set; } + public partial CommandFormSummary? SelectedForm { get; set; } [ObservableProperty] public partial string StatusMessage { get; set; } @@ -43,7 +43,7 @@ public partial class CommandFormsPageViewModel : ViewModelBase } public CommandFormsPageViewModel( - ActivityBrowseItemDto activity, + ActivityInfo activity, ActivityUserDisplayItem performer, BillingApiClient billingClient) { @@ -51,7 +51,7 @@ public partial class CommandFormsPageViewModel : ViewModelBase Performer = performer ?? throw new ArgumentNullException(nameof(performer)); _billingClient = billingClient ?? throw new ArgumentNullException(nameof(billingClient)); - Forms = new ObservableCollection((activity.Forms ?? new()) + Forms = new ObservableCollection((activity.Forms ?? new()) .OrderBy(f => f.Title) .ThenBy(f => f.ActionName)); SelectedForm = Forms.FirstOrDefault(); @@ -81,7 +81,7 @@ public partial class CommandFormsPageViewModel : ViewModelBase throw new InvalidOperationException("Application PostIt indisponible."); } - var vm = new BillingCommandPageViewModel(Activity, Performer, SelectedForm, _billingClient); + var vm = SelectedForm.CreateCommandPageViewModel(Activity, Performer, _billingClient); await vm.InitializeAsync(); await app.PushPageAsync(vm); } @@ -131,4 +131,4 @@ public partial class CommandFormsPageViewModel : ViewModelBase await vm.InitializeAsync(); await app.PushPageAsync(vm); } -} \ No newline at end of file +} diff --git a/src/Yavsc.Abstract/Workflow/ActivityBrowseItemDto.cs b/src/Yavsc.Abstract/Workflow/ActivityInfo.cs similarity index 72% rename from src/Yavsc.Abstract/Workflow/ActivityBrowseItemDto.cs rename to src/Yavsc.Abstract/Workflow/ActivityInfo.cs index cb48b321..c0f543f4 100644 --- a/src/Yavsc.Abstract/Workflow/ActivityBrowseItemDto.cs +++ b/src/Yavsc.Abstract/Workflow/ActivityInfo.cs @@ -3,7 +3,7 @@ namespace Yavsc.Abstract.Workflow; /// /// Activity node returned by the browsing API. /// -public sealed class ActivityBrowseItemDto +public sealed class ActivityInfo { public string Code { get; set; } = string.Empty; public string Name { get; set; } = string.Empty; @@ -12,6 +12,6 @@ public sealed class ActivityBrowseItemDto public string Photo { get; set; } = string.Empty; public int Rate { get; set; } public int PerformerCount { get; set; } - public List Forms { get; set; } = new(); - public List Children { get; set; } = new(); + public List Forms { get; set; } = new(); + public List Children { get; set; } = new(); } diff --git a/src/Yavsc.Abstract/Workflow/CommandFormSummaryDto.cs b/src/Yavsc.Abstract/Workflow/CommandFormSummary.cs similarity index 86% rename from src/Yavsc.Abstract/Workflow/CommandFormSummaryDto.cs rename to src/Yavsc.Abstract/Workflow/CommandFormSummary.cs index c5322ca0..865690e0 100644 --- a/src/Yavsc.Abstract/Workflow/CommandFormSummaryDto.cs +++ b/src/Yavsc.Abstract/Workflow/CommandFormSummary.cs @@ -3,7 +3,7 @@ namespace Yavsc.Abstract.Workflow; /// /// Lightweight command-form description exposed to API clients. /// -public sealed class CommandFormSummaryDto +public sealed class CommandFormSummary { public long Id { get; set; } public string ActionName { get; set; } = string.Empty; diff --git a/src/Yavsc.Abstract/Workflow/ActivityPerformerDto.cs b/src/Yavsc.Abstract/Workflow/PerformerActivity.cs similarity index 94% rename from src/Yavsc.Abstract/Workflow/ActivityPerformerDto.cs rename to src/Yavsc.Abstract/Workflow/PerformerActivity.cs index 4c3df6b8..a5ee3b25 100644 --- a/src/Yavsc.Abstract/Workflow/ActivityPerformerDto.cs +++ b/src/Yavsc.Abstract/Workflow/PerformerActivity.cs @@ -3,7 +3,7 @@ namespace Yavsc.Abstract.Workflow; /// /// Lightweight performer description returned for one activity. /// -public sealed class ActivityPerformerDto +public sealed class PerformerActivity { public string PerformerId { get; set; } = string.Empty; public bool HasPerformerProfile { get; set; } diff --git a/src/Yavsc.Api.Client/ActivityApiClient.cs b/src/Yavsc.Api.Client/ActivityApiClient.cs index 56c7e4fb..9214e7db 100644 --- a/src/Yavsc.Api.Client/ActivityApiClient.cs +++ b/src/Yavsc.Api.Client/ActivityApiClient.cs @@ -30,7 +30,7 @@ public sealed class ActivityApiClient _baseAddress = new Uri(businessBaseAddress, UriKind.Absolute); } - public Task> GetCatalogAsync( + public Task> GetCatalogAsync( string? parentCode = null, CancellationToken ct = default) { @@ -38,23 +38,23 @@ public sealed class ActivityApiClient ? $"{PathPrefix}/catalog" : $"{PathPrefix}/catalog?parentCode={Uri.EscapeDataString(parentCode)}"; - return _api.CallAsync>(HttpMethod.Get, Absolute(path), ct: ct); + return _api.CallAsync>(HttpMethod.Get, Absolute(path), ct: ct); } - public Task> GetUsersAsync( + public Task> GetUsersAsync( string activityCode, CancellationToken ct = default) { if (string.IsNullOrWhiteSpace(activityCode)) throw new ArgumentException("Activity code is required.", nameof(activityCode)); - return _api.CallAsync>( + return _api.CallAsync>( HttpMethod.Get, Absolute($"{PathPrefix}/{Uri.EscapeDataString(activityCode)}/users"), ct: ct); } - public Task> GetPerformersAsync( + public Task> GetPerformersAsync( string activityCode, CancellationToken ct = default) => GetUsersAsync(activityCode, ct); diff --git a/src/Yavsc.Api.Test/ActivityApiControllerTests.cs b/src/Yavsc.Api.Test/ActivityApiControllerTests.cs index a594eb5c..0525e349 100644 --- a/src/Yavsc.Api.Test/ActivityApiControllerTests.cs +++ b/src/Yavsc.Api.Test/ActivityApiControllerTests.cs @@ -42,7 +42,7 @@ public sealed class ActivityApiControllerTests : IClassFixture>(TestContext.Current.CancellationToken); + var payload = await response.Content.ReadFromJsonAsync>(TestContext.Current.CancellationToken); Assert.NotNull(payload); Assert.Single(payload!); Assert.Equal("alice", payload[0].PerformerId); @@ -68,7 +68,7 @@ public sealed class ActivityApiControllerTests : IClassFixture>(TestContext.Current.CancellationToken); + var payload = await response.Content.ReadFromJsonAsync>(TestContext.Current.CancellationToken); Assert.NotNull(payload); Assert.Single(payload!); Assert.Equal("alice", payload[0].PerformerId); @@ -84,7 +84,7 @@ public sealed class ActivityApiControllerTests : IClassFixture>(TestContext.Current.CancellationToken); + var catalog = await catalogResponse.Content.ReadFromJsonAsync>(TestContext.Current.CancellationToken); Assert.NotNull(catalog); var dev = catalog!.Single(a => a.Code == "dev"); @@ -93,7 +93,7 @@ public sealed class ActivityApiControllerTests : IClassFixture>(TestContext.Current.CancellationToken); + var performers = await performersResponse.Content.ReadFromJsonAsync>(TestContext.Current.CancellationToken); Assert.NotNull(performers); Assert.Equal(dev.PerformerCount, performers!.Count); Assert.Contains(performers, p => p.PerformerId == "alice"); @@ -108,7 +108,7 @@ public sealed class ActivityApiControllerTests : IClassFixture>(TestContext.Current.CancellationToken); + var catalog = await catalogResponse.Content.ReadFromJsonAsync>(TestContext.Current.CancellationToken); Assert.NotNull(catalog); Assert.DoesNotContain(catalog!, a => a.Code == "ghost"); Assert.Contains(catalog!, a => a.Code == "dev"); @@ -123,13 +123,13 @@ public sealed class ActivityApiControllerTests : IClassFixture>(TestContext.Current.CancellationToken); + var catalog = await catalogResponse.Content.ReadFromJsonAsync>(TestContext.Current.CancellationToken); Assert.NotNull(catalog); Assert.Contains(catalog!, a => a.Code == "declared-only"); var response = await http.GetAsync("/api/v1/activity/declared-only/users", TestContext.Current.CancellationToken); Assert.Equal(HttpStatusCode.OK, response.StatusCode); - var payload = await response.Content.ReadFromJsonAsync>(TestContext.Current.CancellationToken); + var payload = await response.Content.ReadFromJsonAsync>(TestContext.Current.CancellationToken); Assert.NotNull(payload); Assert.Single(payload!); Assert.Equal("bob", payload[0].PerformerId); @@ -149,8 +149,8 @@ public sealed class ActivityApiControllerTests : IClassFixture>(TestContext.Current.CancellationToken); - var performersPayload = await performersResponse.Content.ReadFromJsonAsync>(TestContext.Current.CancellationToken); + var usersPayload = await usersResponse.Content.ReadFromJsonAsync>(TestContext.Current.CancellationToken); + var performersPayload = await performersResponse.Content.ReadFromJsonAsync>(TestContext.Current.CancellationToken); Assert.NotNull(usersPayload); Assert.NotNull(performersPayload); diff --git a/src/Yavsc.Api/Controllers/Business/ActivityApiController.cs b/src/Yavsc.Api/Controllers/Business/ActivityApiController.cs index f0fdaa1a..a8d28806 100644 --- a/src/Yavsc.Api/Controllers/Business/ActivityApiController.cs +++ b/src/Yavsc.Api/Controllers/Business/ActivityApiController.cs @@ -29,7 +29,7 @@ namespace Yavsc.Controllers } [HttpGet("catalog")] - public async Task>> GetCatalog( + public async Task>> GetCatalog( CancellationToken cancellationToken, [FromQuery] string parentCode = null) { @@ -74,7 +74,7 @@ namespace Yavsc.Controllers } [HttpGet("{id}/users")] - public async Task>> GetUsers( + public async Task>> GetUsers( [FromRoute] string id, CancellationToken cancellationToken) { @@ -97,7 +97,7 @@ namespace Yavsc.Controllers } [HttpGet("{id}/performers")] - public Task>> GetPerformers( + public Task>> GetPerformers( [FromRoute] string id, CancellationToken cancellationToken) { @@ -105,7 +105,7 @@ namespace Yavsc.Controllers return GetUsers(id, cancellationToken); } - private Task> QueryDeclaredUsersAsync( + private Task> QueryDeclaredUsersAsync( string activityCode, string activityName, CancellationToken cancellationToken) @@ -118,7 +118,7 @@ namespace Yavsc.Controllers from performer in performerProfiles.DefaultIfEmpty() where ua.DoesCode == activityCode orderby user != null ? user.UserName : ua.UserId - select new ActivityPerformerDto + select new PerformerActivity { PerformerId = ua.UserId, HasPerformerProfile = performer != null, @@ -260,11 +260,11 @@ namespace Yavsc.Controllers return _context.Activities.Count(e => e.Code == id) > 0; } - private static ActivityBrowseItemDto ToBrowseItem( + private static ActivityInfo ToBrowseItem( Activity activity, IReadOnlyDictionary performerCounts) { - return new ActivityBrowseItemDto + return new ActivityInfo { Code = activity.Code, Name = activity.Name, @@ -274,7 +274,7 @@ namespace Yavsc.Controllers Rate = activity.Rate, PerformerCount = performerCounts.TryGetValue(activity.Code, out var count) ? count : 0, Forms = (activity.Forms ?? Enumerable.Empty()) - .Select(f => new CommandFormSummaryDto + .Select(f => new CommandFormSummary { Id = f.Id, ActionName = f.ActionName, @@ -285,7 +285,7 @@ namespace Yavsc.Controllers .Where(c => !c.Hidden) .Where(c => performerCounts.TryGetValue(c.Code, out var childCount) && childCount > 0) .OrderByDescending(c => c.Rate) - .Select(c => new ActivityBrowseItemDto + .Select(c => new ActivityInfo { Code = c.Code, Name = c.Name, @@ -295,7 +295,7 @@ namespace Yavsc.Controllers Rate = c.Rate, PerformerCount = performerCounts.TryGetValue(c.Code, out var childCount) ? childCount : 0, Forms = (c.Forms ?? Enumerable.Empty()) - .Select(f => new CommandFormSummaryDto + .Select(f => new CommandFormSummary { Id = f.Id, ActionName = f.ActionName,