public void RemoveLot(LotInformation info) { var listLotInformation = _product.GetListLotInformation(); foreach (LotInformation lot in listLotInformation) { if (lot.Equals(info)) { _product.TotalQuantityProduct -= lot.QuantityProduct; listLotInformation.Remove(lot); break; } } }
public void AddLot(LotInformation info) { _product.TotalQuantityProduct += info.QuantityProduct; UpdateProductCharacteristic(); var listLotInfo = _product.GetListLotInformation(); foreach (LotInformation inf in listLotInfo) { if (inf.EqualsProductionDate(info)) { inf.QuantityProduct += info.QuantityProduct; return; } } listLotInfo.Add(info); }
public ProductFromLot GetProductFromLot(int number) { _product.TotalQuantityProduct -= number; ProductFromLot productFromLot = new ProductFromLot(); productFromLot.ProductName = (string)_product.ProductName.Clone(); productFromLot.ProduceCountry = (string)_product.ProduceCountry.Clone(); productFromLot.ProductGroup = (string)_product.ProductGroup.Clone(); productFromLot.Price = _product.Price; productFromLot.ProductCategory = (string)_product.ProductCategory.Clone(); productFromLot.ProductId = _product.ProductId; productFromLot.Measure = (Measure)_product.Measure.Clone(); productFromLot.ExpirationDate = _product.ExpirationDate; DateTime oldestProduct = new DateTime(1, 1, 1); LotInformation clientLot = new LotInformation(); List <LotInformation> lotsForRemove = new List <LotInformation>(); var listLotInformation = _product.GetListLotInformation(); foreach (LotInformation lot in listLotInformation) { if (lot.QuantityProduct >= number) { clientLot.QuantityProduct += number; if (oldestProduct.Equals(new DateTime(1, 1, 1))) { clientLot.ProductionDate = lot.ProductionDate; } if (lot.QuantityProduct == number) { lotsForRemove.Add(lot); } lot.QuantityProduct -= number; break; } else { clientLot.QuantityProduct += lot.QuantityProduct; number -= lot.QuantityProduct; if (oldestProduct.Equals(new DateTime(1, 1, 1))) { clientLot.ProductionDate = lot.ProductionDate; oldestProduct = lot.ProductionDate; } lotsForRemove.Add(lot); } } productFromLot.Lot.ProductionDate = clientLot.ProductionDate; productFromLot.Lot.QuantityProduct = clientLot.QuantityProduct; foreach (var lot in lotsForRemove) { listLotInformation.Remove(lot); } return(productFromLot); }
public bool EqualsProductionDate(LotInformation info) { return(ProductionDate.Equals(info.ProductionDate)); }
public bool Equals(LotInformation lot) { return(ProductionDate.Equals(lot.ProductionDate) && QuantityProduct == lot.QuantityProduct); }