Adding
This commit is contained in:
+87
@@ -0,0 +1,87 @@
|
||||
using LCU.API.Internal.RepoApi.Repos.Extensions;
|
||||
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 AuctionAssignmentRepository : BaseRepository, IAuctionAssignmentRepository
|
||||
{
|
||||
public AuctionAssignmentRepository(AppDbContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<PagedResult<AuctionAssignment>> ListAllAsync(int filterPage, int filterLimit)
|
||||
{
|
||||
var results = new PagedResult<AuctionAssignment>();
|
||||
var skip = (filterPage - 1) * filterLimit;
|
||||
|
||||
var temp = (from x in _context.AuctionAssignments
|
||||
select x).OrderByDescending(x => x.ID);
|
||||
|
||||
results.Total = temp.Count();
|
||||
results.Items = await temp.Skip(skip).Take(filterLimit).IncludeAll().ToListAsync();
|
||||
return results;
|
||||
}
|
||||
|
||||
public async Task<PagedResult<AuctionAssignment>> ListReadyForFloorPriceAsync()
|
||||
{
|
||||
var results = new PagedResult<AuctionAssignment>();
|
||||
|
||||
var temp = (from x in _context.AuctionAssignments
|
||||
where (x.FloorPrice ?? 0) == 0 && x.AutoIMS != null && x.AutoIMS.SoldDate == null &&
|
||||
(x.AutoIMS.StatedMileage ?? -1) > 1 && x.AutoIMS.ScheduledSaleDate != null &&
|
||||
x.AutoIMS.ScheduledSaleDate > DateTime.Now.Date &&
|
||||
x.RedeemedDate == null &&
|
||||
( (x.AutoIMS.ApprovedVehicleGrade ?? 0) > 0 || (x.AutoIMS.VehicleGrade ?? 0) > 0)
|
||||
select x).OrderByDescending(x => x.ID);
|
||||
|
||||
results.Items = await temp.IncludeAll().ToListAsync();
|
||||
results.Total = temp.Count();
|
||||
return results;
|
||||
}
|
||||
|
||||
public async Task<AuctionAssignment> FindByIdAsync(int id)
|
||||
{
|
||||
return await Queryable.Where(_context.AuctionAssignments, c => c.ID == id).IncludeAll().FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyCollection<AuctionAssignment>> FindListByIdsAsync(IReadOnlyCollection<int> idSet)
|
||||
{
|
||||
return await Queryable.Where(_context.AuctionAssignments, c => idSet.Contains(c.ID)).ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyCollection<AuctionAssignment>> FindByRepoIdAsync(int repoId)
|
||||
{
|
||||
return await _context.AuctionAssignments.Where(auctionAssignment => auctionAssignment.RepoId == repoId).IncludeAll().ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<AuctionAssignment> FindByByAuctionCustomerNoAndVin(string auctionCustomerNo, string vin)
|
||||
{
|
||||
return await Queryable
|
||||
.Where(_context.AuctionAssignments, auctionAssignment =>
|
||||
auctionAssignment.AuctionCustomerNo == auctionCustomerNo &&
|
||||
auctionAssignment.CollateralVIN == vin &&
|
||||
auctionAssignment.IsActive == true).IncludeAll().FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<AuctionAssignment> AddAsync(AuctionAssignment auctionAssignment)
|
||||
{
|
||||
var result = await _context.AuctionAssignments.AddAsync(auctionAssignment);
|
||||
result.Entity.Auction = Queryable.Where(_context.Auctions, a => a.AuctionID == result.Entity.AuctionId)
|
||||
.FirstOrDefault();
|
||||
return result.Entity;
|
||||
}
|
||||
|
||||
public void Update(AuctionAssignment auctionAssignment)
|
||||
{
|
||||
_context.AuctionAssignments.Update(auctionAssignment);
|
||||
}
|
||||
|
||||
public void Remove(AuctionAssignment auctionAssignment)
|
||||
{
|
||||
_context.AuctionAssignments.Remove(auctionAssignment);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user