Exemplo n.º 1
0
        public bool CollectMaterial(int amount, int?materialId, int?productionId, int?customerOrderId)
        {
            // wenn materialId nicht befuellt ist, dann handelt es sich um ein Fertigprodukt
            if ((materialId == null || materialId == 0) && productionId != null && customerOrderId != null)
            {
                ProducedProduct newProdProduct = new ProducedProduct();
                newProdProduct.Amount       = amount;
                newProdProduct.CustOrderId  = customerOrderId.GetValueOrDefault();
                newProdProduct.ProductionId = productionId.GetValueOrDefault();
                _context.ProducedProduct.Add(newProdProduct);
                _context.SaveChanges();
                return(true);
            }
            // wenn wieder Farbe eingelagert werden muss
            else
            {
                materialId = materialId.GetValueOrDefault();
                // Material updaten
                Material materialFromDB = _context.Material.Find(materialId);
                if (materialFromDB == null)
                {
                    // Create koennte man nur machen, wenn auch die SupplierId mit uebergeben wird
                    return(false);
                }
                materialFromDB.MinStock = materialFromDB.MinStock.Value + amount;

                _context.Entry(materialFromDB).CurrentValues.SetValues(amount);
                _context.SaveChanges();
                return(true);
            }
        }
Exemplo n.º 2
0
        private bool updateProducedProductFromCollectionOrder(CollectionOrder colOrder, int?productionId)
        {
            if (colOrder != null && productionId != null)
            {
                ProducedProduct newProducedProduct = new ProducedProduct
                {
                    ProductionId      = productionId.GetValueOrDefault(),
                    CustOrderId       = colOrder.CustOrderId.GetValueOrDefault(),
                    CollectionOrderId = colOrder.CollectionId,
                    Amount            = colOrder.Amount.GetValueOrDefault()
                };
                _context.ProducedProduct.Add(newProducedProduct);
                //_context.Entry(newCollectionOrder).CurrentValues.SetValues(data);
                _context.SaveChanges();

                return(true);
            }
            return(false);
        }