public IEnumerable <Batch> ProductsPast75PercentOfShelfLife() { List <Batch> ProductsInStoreList = new List <Batch>(); ProductsInStoreList = BatchRepo.GetAll(x => (x.QuantitySold + x.QuantityAuctioned + x.QuantityDisposedOf) < x.QuantityPurchased).ToList(); List <Batch> SoonToExpireProductsInList = new List <Batch>(); foreach (var item in ProductsInStoreList) { DateTime ManufactureDate = item.ManufactureDate; DateTime ExpiryDate = item.ExpiryDate; if (ExpiryDate > DateTime.Now) { if (IsProductPast75PercentOfShelfLife(item)) { if (ProductToBeAuctionedRepo.GetAll(x => x.BatchId == item.Id).FirstOrDefault() == null && AuctionRepo.GetAll(x => x.BatchId == item.Id).FirstOrDefault() == null) { ProductToBeAuctionedRepo.Add(new ProductToBeAuctioned() { AuctionPrice = 0, HasBeenReviewedByManager = false, BatchId = item.Id, //StoreId = new StoreManager().GetStoreId(), DateOfAuction = ReturnAuctionDateUsingPercentageOfShelfLife(80, item), }); } SoonToExpireProductsInList.Add(item); } } } return(SoonToExpireProductsInList); }
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); }
public PartialViewResult ProductsByStore(Guid id) { List <OnAuctionVM> AuctionResult = new List <OnAuctionVM>(); Store Store = StoreRepo.Get(x => x.Id == id); List <Auction> Auctions = new List <Auction>(); Auctions = AuctionRepo.GetAll(x => x.Batch.Product.StoreId == id).ToList(); foreach (var item in Auctions) { AuctionResult.Add(new OnAuctionVM() { Auction = item, Batch = item.Batch, Product = item.Batch.Product }); } ViewBag.storeName = Store.Name; ViewBag.categories = AuctionResult.Select(x => x.Product.Category).Distinct().ToList(); return(PartialView(AuctionResult)); }