Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

Commit

Permalink
fix(back-end): Use 'DateDiffDay' function to avoid ef errors
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosPavajeau committed Jan 27, 2021
1 parent 0659462 commit 0a15300
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Infrastructure/Repositories/ProductInvoicesRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public ProductInvoicesRepository(ApplicationDbContext applicationDbContext) : ba
public async Task<IEnumerable<ProductInvoice>> GetPendingExpiredProductInvoices()
{
return await GetAll().Include(s => s.Client).Include(s => s.ProductInvoiceDetails)
.Where(s => s.State == InvoiceState.Generated && (DateTime.Now - s.GenerationDate).Days >= Invoice.DayLimits)
.Where(s => s.State == InvoiceState.Generated &&
MySqlDbFunctionsExtensions.DateDiffDay(EF.Functions, DateTime.Now, s.GenerationDate) >= Invoice.DayLimits)
.ToListAsync();
}

Expand Down
6 changes: 4 additions & 2 deletions Infrastructure/Repositories/ServiceInvoicesRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ public async Task<IEnumerable<ServiceInvoice>> GetClientInvoices(string clientId

public async Task<IEnumerable<ServiceInvoice>> GetPendingExpiredServiceInvoices()
{
return await GetAll().Include(s => s.Client).Include(s => s.ServiceInvoiceDetails)
.Where(s => s.State == InvoiceState.Generated && (DateTime.Now - s.GenerationDate).Days >= Invoice.DayLimits)
return await GetAll().Include(s => s.Client)
.Include(s => s.ServiceInvoiceDetails)
.Where(s => s.State == InvoiceState.Generated &&
MySqlDbFunctionsExtensions.DateDiffDay(EF.Functions, DateTime.Now, s.GenerationDate) >= Invoice.DayLimits)
.ToListAsync();
}
}
Expand Down

0 comments on commit 0a15300

Please sign in to comment.