42 lines
1.6 KiB
C#
42 lines
1.6 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Logging;
|
|
using PARR.DAL.Context;
|
|
using PARR.DAL.Extensions;
|
|
using PARR.DAL.Models.V1;
|
|
using PARR.DAL.Services.Abstracts;
|
|
using PARR.DAL.Services.Interfaces.V1;
|
|
|
|
namespace PARR.DAL.Services.Implementations.V1
|
|
{
|
|
internal class V1_JobJournalService : BaseService<V1_JobJournal>, V1_IJobJournalService
|
|
{
|
|
private readonly DataContext dataContext;
|
|
private readonly ILogger<V1_JobJournalService> logger;
|
|
|
|
public V1_JobJournalService(DataContext dataContext, ILogger<V1_JobJournalService> logger) : base(logger)
|
|
{
|
|
this.dataContext = dataContext;
|
|
this.logger = logger;
|
|
}
|
|
protected override DbSet<V1_JobJournal> EntitySet => dataContext.JobJournals;
|
|
|
|
protected override DataContext EntitiContext => dataContext;
|
|
|
|
public async Task<V1_JobJournal?> GetLastAsync(Guid jobId, Guid hostId, DateTimeOffset date)
|
|
{
|
|
//var n=DateTimeOffset.UtcNow;
|
|
//var opers = await EntitySet
|
|
// .Where(j => j.JobId == jobId && j.HostId == hostId && (j.DateOper!=DateTimeOffset.MinValue))/*date.StartOfDay()*/// && j.DateOper < date.EndOfDay()))
|
|
// .OrderBy(t => t.DateOper)
|
|
// .LastOrDefaultAsync();
|
|
|
|
var opers = await EntitySet
|
|
.Where(j => j.JobId == jobId && j.HostId == hostId && j.DateOper.DateTime.Date == date.DateTime.Date)
|
|
.OrderBy(t => t.DateOper)
|
|
.LastOrDefaultAsync();
|
|
|
|
return opers;
|
|
}
|
|
}
|
|
}
|