53 lines
2.1 KiB
C#
53 lines
2.1 KiB
C#
using LCU.API.Internal.RepoApi.Repos.Models;
|
|
using LCU.API.Internal.RepoApi.Repos.Models.Results;
|
|
using LCU.API.Internal.RepoApi.Repos.Persistence;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace LCU.API.Internal.RepoApi.Repos.Repositories
|
|
{
|
|
public class AuctionAssignmentNoteRepository : BaseRepository, IAuctionAssignmentNoteRepository
|
|
{
|
|
public AuctionAssignmentNoteRepository(AppDbContext context) : base(context) { }
|
|
|
|
public async Task<PagedResult<AuctionAssignmentNote>> ListAllAsync(int filterPage, int filterLimit)
|
|
{
|
|
var results = new PagedResult<AuctionAssignmentNote>();
|
|
var skip = (filterPage - 1) * filterLimit;
|
|
|
|
var temp = Queryable.OrderByDescending(from x in _context.AuctionAssignmentNotes
|
|
select x, x => x.Id);
|
|
|
|
results.Total = temp.Count();
|
|
results.Items = await temp.Skip(skip).Take(filterLimit).ToListAsync();
|
|
return results;
|
|
}
|
|
|
|
public async Task<AuctionAssignmentNote> FindByIdAsync(int id)
|
|
{
|
|
return await Queryable.Where(_context.AuctionAssignmentNotes, c => c.Id == id).FirstOrDefaultAsync();
|
|
}
|
|
|
|
public async Task<IEnumerable<AuctionAssignmentNote>> FindConflictingNotes(DateTime written, string text, string writer)
|
|
{
|
|
return await Queryable.Where(_context.AuctionAssignmentNotes, c => c.DateWritten == written && c.Text == text && c.Writer == writer).ToListAsync();
|
|
}
|
|
|
|
public async Task<AuctionAssignmentNote> AddAsync(AuctionAssignmentNote auctionAssignmentNote)
|
|
{
|
|
var result = await _context.AuctionAssignmentNotes.AddAsync(auctionAssignmentNote);
|
|
return result.Entity;
|
|
}
|
|
|
|
public void Update(AuctionAssignmentNote auctionAssignmentNote)
|
|
{
|
|
_context.AuctionAssignmentNotes.Update(auctionAssignmentNote);
|
|
}
|
|
|
|
public void Remove(AuctionAssignmentNote auctionAssignmentNote)
|
|
{
|
|
_context.AuctionAssignmentNotes.Remove(auctionAssignmentNote);
|
|
}
|
|
}
|
|
}
|