Skip to content

Commit

Permalink
feat: add search to price rate
Browse files Browse the repository at this point in the history
  • Loading branch information
Jangkuz committed Jul 10, 2024
1 parent fb67ec8 commit bf77f71
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 139 deletions.
1 change: 1 addition & 0 deletions backend/Helper/PriceRateQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class PriceRateQuery
public long? AccountId { get; set; }
public float? Percent { get; set; }
public DateTime? createdAt { get; set; }
public DateTime? SearchCreatedAt { get; set; }

public int PageSize { get; set; } = 10;
public int PageNumber { get; set; } = 1;
Expand Down
7 changes: 7 additions & 0 deletions backend/Repository/PriceRateRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public async Task<PriceRateResult> GetAllPriceRateAsync(PriceRateQuery query)
{
var priceRateQueries = _context.PriceRates.Include(x => x.Account).OrderByDescending(x => x.CreatedAt).AsQueryable();

if (query.SearchCreatedAt.HasValue)
{
priceRateQueries = priceRateQueries.Where(pr =>
pr.CreatedAt <= query.SearchCreatedAt
);
}

var totalCount = await priceRateQueries.CountAsync();
var totalPages = (int)Math.Ceiling((double)totalCount / query.PageSize);

Expand Down
Loading

0 comments on commit bf77f71

Please sign in to comment.