//Проверка на наличие наименования продукта на складе. В случае, если наименование отсутствует на складе, Сервису необходимо создать новый StorehouseProduct //и добавить его в хранилище. public bool ContainsProduct(ProductFromLot prod) { if (_productStorage.ContainsKey(prod.ProductCategory)) { SortedDictionary <string, List <StorehouseProduct> > dictCategory = _productStorage[prod.ProductCategory]; if (dictCategory.ContainsKey(prod.ProductGroup)) { List <StorehouseProduct> listProducts = dictCategory[prod.ProductGroup]; foreach (StorehouseProduct pr in listProducts) { if (pr.ProductName.Equals(prod.ProductName) && pr.Price.Equals(prod.Price) && pr.Measure.Equals(prod.Measure)) { return(true); } } return(false); } else { return(false); } } else { return(false); } }
public void RemoveProduct(ProductFromLot prod) { if (_listProducts.Remove(prod)) { TotalSumOrder -= (prod.Price * prod.Lot.QuantityProduct); } }
private void TestCatalog() { ProductFromLot prod = new ProductFromLot(); prod.Measure = new MeasureKilogram(); prod.Price = 3; prod.ExpirationDate = 30; prod.ProduceCountry = "Беларусь"; prod.ProductCategory = "Мясные полуфабрикаты"; prod.ProductGroup = "Пельмени"; prod.ProductName = "Мясные подушечки"; prod.Lot.QuantityProduct = 30; prod.Lot.ProductionDate = new DateTime(2010, 10, 10); AddProduct(prod); ProductFromLot prod1 = new ProductFromLot(); prod1.Measure = new MeasureKilogram(); prod1.Price = 4; prod1.ExpirationDate = 30; prod1.ProduceCountry = "Беларусь"; prod1.ProductCategory = "Мясные полуфабрикаты"; prod1.ProductGroup = "Пельмени"; prod1.ProductName = "Бабушка Аня"; prod1.Lot.ProductionDate = new DateTime(2010, 10, 10); prod1.Lot.QuantityProduct = 40; AddProduct(prod1); ProductFromLot prod2 = new ProductFromLot(); prod2.Measure = new MeasureKilogram(); prod2.Price = 9; prod2.ExpirationDate = 30; prod2.ProduceCountry = "Беларусь"; prod2.ProductCategory = "Мясные полуфабрикаты"; prod2.ProductGroup = "Разделка свинная"; prod2.ProductName = "Хряк"; prod2.Lot.ProductionDate = new DateTime(2010, 10, 10); prod2.Lot.QuantityProduct = 50; AddProduct(prod2); ProductFromLot prod3 = new ProductFromLot(); prod3.Measure = new MeasureKilogram(); prod3.Price = 1; prod3.ExpirationDate = 15; prod3.ProduceCountry = "Беларусь"; prod3.ProductCategory = "Молочная продукция"; prod3.ProductGroup = "Творожные изделия"; prod3.ProductName = "101 зерно"; prod3.Lot.ProductionDate = new DateTime(2010, 10, 10); prod3.Lot.QuantityProduct = 15; AddProduct(prod3); }
public StorehouseProduct(ProductFromLot prod) : this() { ProductCategory = (string)prod.ProductCategory.Clone(); ProduceCountry = (string)prod.ProduceCountry.Clone(); ProductGroup = (string)prod.ProductGroup.Clone(); ProductName = (string)prod.ProductName.Clone(); TotalQuantityProduct += prod.Lot.QuantityProduct; _listLotInformation.Add(prod.Lot); Measure = (Measure)prod.Measure.Clone(); Price = prod.Price; }
public ProductFromLot GetProduct(int productId, int numberOfProduct) { StorehouseProduct baseProd = FindStorehouseProductById(productId); IServiceForStorehouseProduct service = _kernel.Get <IServiceForStorehouseProduct>(); service.SetStorehouseProduct(baseProd); ProductFromLot prod = service.GetProductFromLot(numberOfProduct); service.UpdateProductCharacteristic(); return(prod); }
public void AddProduct(int orderId, int productId, int numberOfProduct) { ProductFromLot prod = new ProductFromLot(); prod.ProductId = productId; prod.Lot.QuantityProduct = numberOfProduct; _addedProducts[orderId].Add(prod); var order = _orders[orderId]; var serviceForAddingProductsInClientOrder = _kernel.Get <IServiceForAddingProductsInClientOrder>(); serviceForAddingProductsInClientOrder.SetClientOrder(order); serviceForAddingProductsInClientOrder.AddProduct(productId, numberOfProduct); }
public void AddProduct(ProductFromLot prod) { bool contains = _repository.ContainsProduct(prod); if (contains) { _repository.AddProductFromLot(prod); } else { StorehouseProduct storehouseProduct = new StorehouseProduct(prod); storehouseProduct.ProductId = GetProductId(); IServiceForStorehouseProduct service = _kernel.Get <IServiceForStorehouseProduct>(); service.SetStorehouseProduct(storehouseProduct); service.UpdateProductCharacteristic(); _repository.AddStoreHouseProduct(storehouseProduct); } }
public void AddProductFromLot(ProductFromLot prod) { var dictCategory = _productStorage[prod.ProductCategory]; var listProducts = dictCategory[prod.ProductGroup]; foreach (StorehouseProduct pr in listProducts) { if (pr.ProductName.Equals(prod.ProductName) && pr.Price.Equals(prod.Price) && pr.Measure.Equals(prod.Measure)) { IServiceForStorehouseProduct service = _kernel.Get <IServiceForStorehouseProduct>(); service.SetStorehouseProduct(pr); service.AddLot(prod.Lot); service.UpdateProductCharacteristic(); break; } } }
public void RemoveProduct(int orderId, int productId) { var listProd = _orders[orderId].GetListProducts(); ProductFromLot prod = null; foreach (var pr in listProd) { if (pr.ProductId == productId) { prod = (ProductFromLot)pr.Clone(); } break; } _removedProducts[orderId].Add(prod); var order = _orders[orderId]; var serviceForAddingProductsInClientOrder = _kernel.Get <IServiceForAddingProductsInClientOrder>(); serviceForAddingProductsInClientOrder.SetClientOrder(order); serviceForAddingProductsInClientOrder.RemoveProduct(productId); }
public void AddProductFromDelivery(ProductFromLot prod) { AddProduct(prod); }
public void AddProduct(ProductFromLot prod) { _listProducts.Add(prod); TotalSumOrder += (prod.Price * prod.Lot.QuantityProduct); }
public void RemoveProduct(ProductFromLot prod) { _listClientProduct.Remove(prod); }
public void AddProduct(ProductFromLot prod) { _listClientProduct.Add(prod); }
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); }