Skip to content

Commit e33db8a

Browse files
Added search by client ID in projects
1 parent 03d5180 commit e33db8a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/dotnet/HQ.Abstractions/Projects/GetProjectsV1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class Request : PagedRequestV1
1515
{
1616
public string? Search { get; set; }
1717
public Guid? Id { get; set; }
18-
18+
public Guid? clientId { get; set; }
1919
public SortColumn SortBy { get; set; } = SortColumn.Name;
2020
public SortDirection SortDirection { get; set; } = SortDirection.Asc;
2121
}

src/dotnet/HQ.Server/Services/ProjectServiceV1.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,15 @@ public ProjectServiceV1(HQDbContext context)
8383
.OrderByDescending(t => t.CreatedAt)
8484
.AsQueryable();
8585

86-
var total = await records.CountAsync(ct);
86+
if (request.clientId.HasValue)
87+
{
88+
records = records.Where(t => t.ClientId == request.clientId);
89+
}
8790

8891
if (!string.IsNullOrEmpty(request.Search))
8992
{
9093
records = records.Where(t =>
91-
t.Name.ToLower().Contains(request.Search.ToLower()) ||
94+
t.Name.ToLower().Contains(request.Search.ToLower()) ||
9295
t.Client.Name.ToLower().Contains(request.Search.ToLower()) ||
9396
(t.ChargeCode != null ? t.ChargeCode.Code.ToLower().Contains(request.Search.ToLower()) : false)
9497
);
@@ -140,6 +143,8 @@ public ProjectServiceV1(HQDbContext context)
140143
{
141144
mapped = mapped.Take(request.Take.Value);
142145
}
146+
147+
var total = await records.CountAsync(ct);
143148

144149
var response = new GetProjectsV1.Response()
145150
{

0 commit comments

Comments
 (0)