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> ListAllAsync(int filterPage, int filterLimit) { var results = new PagedResult(); 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 FindByIdAsync(int id) { return await Queryable.Where(_context.AuctionAssignmentNotes, c => c.Id == id).FirstOrDefaultAsync(); } public async Task> 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 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); } } }