public ActionResult ViewProduct(Guid id) { ViewProductVM Record = new ViewProductVM(); Auction Auction = AuctionRepo.Get(x => x.Id == id); var AvailabelAuctions = AuctionLogic.ViewProductsOnAuction(); var OtherAuctionsByStore = AvailabelAuctions .Where(x => x.Batch.Product.StoreId == Auction.Batch.Product.StoreId && x.Batch.Id != Auction.BatchId) .ToList(); var AuctionsWithSimilarExpiryDate = AvailabelAuctions .Where(x => x.Batch.ExpiryDate == Auction.Batch.ExpiryDate && x.Batch.Id != Auction.BatchId) .ToList(); OnAuctionVM ProductAuction = new OnAuctionVM() { Product = Auction.Batch.Product, Auction = Auction, Batch = Auction.Batch }; Record.Product = ProductAuction; Record.ProductsFromStore = OtherAuctionsByStore; Record.ProductsWithSimilarExpiryDate = AuctionsWithSimilarExpiryDate; return(View(Record)); }
public List <OnAuctionVM> ViewProductsOnAuction() { OnAuctionVM AuctionRecords = new OnAuctionVM(); List <Auction> ActiveAuction = AuctionRepo.GetAll(x => (x.Batch.QuantitySold + x.Batch.QuantityAuctioned) < x.Batch.QuantityPurchased).ToList(); List <OnAuctionVM> FullAuctionReport = new List <OnAuctionVM>(); foreach (var item in ActiveAuction) { FullAuctionReport.Add(new OnAuctionVM() { Auction = item, Batch = item.Batch, Product = item.Batch.Product }); } return(FullAuctionReport); }