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 ProductToBeAuctioned UpdateToBeAuctionedRecord(Guid id, DateTime dateOfAuction, double price) { ProductToBeAuctioned Record = ProductToBeAuctionedRepo.Get(x => x.Id == id); Record.DateOfAuction = dateOfAuction; Record.AuctionPrice = price; return(ProductToBeAuctionedRepo.Update(Record)); }
public ProductToBeAuctioned EditAuctionDateAndPrice(Guid productToBeAuctionId, double price, DateTime auctionDate) { ProductToBeAuctioned Record = ProductToBeAuctionedRepo.Get(x => x.Id == productToBeAuctionId); Record.DateOfAuction = auctionDate; Record.AuctionPrice = price; return(ProductToBeAuctionedRepo.Update(Record)); }
public void ListProductsToBeAuctioned() { List <ProductToBeAuctioned> productsToBeAuctioned = new List <ProductToBeAuctioned>(); ProductToBeAuctionedRepo.GetAll(x => x.HasBeenReviewedByManager == true).ToList().ForEach(productToBeAuctioned => { if (productToBeAuctioned.DateOfAuction.Date == DateTime.Now.Date) { productsToBeAuctioned.Add(productToBeAuctioned); } }); productsToBeAuctioned.ForEach(product => { AuctionRepo.Add(new Auction { AuctionPrice = product.AuctionPrice, BatchId = product.BatchId, }); }); productsToBeAuctioned.Select(x => x.Id).ToList().ForEach(id => { ProductToBeAuctionedRepo.Delete(id); }); }