public static OfferDto GetMostRecentOfferOfType(RioDbContext dbContext, PostingTypeEnum postingTypeEnum) { var offer = dbContext.Offer .Include(x => x.CreateAccount) .Include(x => x.OfferStatus) .Include(x => x.WaterTransfer) .Include(x => x.Trade) .ThenInclude(x => x.CreateAccount) .Include(x => x.Trade) .ThenInclude(x => x.Posting).ThenInclude(x => x.CreateAccount) .Include(x => x.Trade) .ThenInclude(x => x.TradeStatus) .Include(x => x.Trade) .ThenInclude(x => x.Posting) .ThenInclude(x => x.PostingType) .Include(x => x.Trade) .ThenInclude(x => x.Posting) .ThenInclude(x => x.PostingStatus) .AsNoTracking() .Where(x => !x.WaterTransfer.Any() && x.OfferStatusID != (int)OfferStatusEnum.Rejected && x.OfferStatusID != (int)OfferStatusEnum.Rescinded && (x.Trade.Posting.PostingStatusID == (int)postingTypeEnum && x.Trade.Posting.CreateAccountID == x.CreateAccountID) || (x.Trade.Posting.PostingStatusID != (int)postingTypeEnum && x.Trade.Posting.CreateAccountID != x.CreateAccountID)).OrderByDescending(x => x.OfferDate).FirstOrDefault(); return(offer?.AsDto()); }
public static PostingDto GetMostRecentOfferOfType(RioDbContext dbContext, PostingTypeEnum postingTypeEnum) { var offer = GetPostingImpl(dbContext).Where(x => x.PostingTypeID == (int)postingTypeEnum).OrderByDescending(x => x.PostingDate).FirstOrDefault(); return(offer?.AsDto()); }