From a57317971444c3d9ce9d18fbd644d15a854f35d7 Mon Sep 17 00:00:00 2001 From: Chris Chen Date: Thu, 28 May 2026 17:24:47 -0700 Subject: [PATCH] =?UTF-8?q?feat(giving):=20match=20giver=20member=20name?= =?UTF-8?q?=20in=20single-giving=20search=20(spec=20=C2=A74.2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- .../Services/GivingServiceTests.cs | 21 +++++++++++++++++++ API/ROLAC.API/Services/GivingService.cs | 9 ++++++-- .../givings-page/givings-page.component.html | 2 +- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/API/ROLAC.API.Tests/Services/GivingServiceTests.cs b/API/ROLAC.API.Tests/Services/GivingServiceTests.cs index 67d0281..b540fa3 100644 --- a/API/ROLAC.API.Tests/Services/GivingServiceTests.cs +++ b/API/ROLAC.API.Tests/Services/GivingServiceTests.cs @@ -137,4 +137,25 @@ public class GivingServiceTests await Assert.ThrowsAsync(() => svc.DeleteAsync(giving.Id)); } + + [Fact] + public async Task GetPagedAsync_MatchesByMemberName() + { + using var db = BuildDb(); + var catId = await SeedCategoryAsync(db); + var member = new Member { FirstName_en = "Grace", LastName_en = "Lee" }; + db.Members.Add(member); + await db.SaveChangesAsync(); + var svc = new GivingService(db); + await svc.CreateAsync(new CreateGivingRequest + { + GivingCategoryId = catId, Amount = 75m, PaymentMethod = "Cash", + GivingDate = new DateOnly(2026, 5, 31), MemberId = member.Id, + }); + + var page = await svc.GetPagedAsync(1, 20, "grace", null, null, null); + + Assert.Equal(1, page.TotalCount); + Assert.Equal(member.Id, page.Items[0].MemberId); + } } diff --git a/API/ROLAC.API/Services/GivingService.cs b/API/ROLAC.API/Services/GivingService.cs index b3a105f..f9ed2a3 100644 --- a/API/ROLAC.API/Services/GivingService.cs +++ b/API/ROLAC.API/Services/GivingService.cs @@ -21,10 +21,15 @@ public class GivingService : IGivingService if (to.HasValue) query = query.Where(g => g.GivingDate <= to.Value); if (!string.IsNullOrWhiteSpace(search)) { - var s = search.Trim().ToLower(); + var s = search.Trim().ToLower(); + var term = search.Trim(); query = query.Where(g => (g.CheckNumber != null && g.CheckNumber.ToLower().Contains(s)) || - (g.Notes != null && g.Notes.ToLower().Contains(s))); + (g.Notes != null && g.Notes.ToLower().Contains(s)) || + (g.Member != null && ( + (g.Member.FirstName_en + " " + g.Member.LastName_en).ToLower().Contains(s) || + (g.Member.FirstName_zh != null && g.Member.FirstName_zh.Contains(term)) || + (g.Member.LastName_zh != null && g.Member.LastName_zh.Contains(term))))); } var total = await query.CountAsync(); diff --git a/APP/src/app/features/giving/pages/givings-page/givings-page.component.html b/APP/src/app/features/giving/pages/givings-page/givings-page.component.html index 467d23f..c5861a1 100644 --- a/APP/src/app/features/giving/pages/givings-page/givings-page.component.html +++ b/APP/src/app/features/giving/pages/givings-page/givings-page.component.html @@ -5,7 +5,7 @@
- +