/// <summary> /// copies am Article and his Childs to ProductionOrder /// Creates Demand Provider for Production oder and DemandRequests for childs /// </summary> /// <returns></returns> public ProductionOrder CopyArticleToProductionOrder(int articleId, decimal quantity, int demandRequesterId) { var article = Articles.Include(a => a.ArticleBoms).ThenInclude(c => c.ArticleChild).Single(a => a.Id == articleId); var mainProductionOrder = new ProductionOrder { ArticleId = article.Id, Name = "Prod. Auftrag: " + article.Name, Quantity = quantity, }; ProductionOrders.Add(mainProductionOrder); CreateProductionOrderWorkSchedules(mainProductionOrder); var demandProvider = new DemandProviderProductionOrder() { ProductionOrderId = mainProductionOrder.Id, Quantity = quantity, ArticleId = article.Id, DemandRequesterId = demandRequesterId, }; Demands.Add(demandProvider); SaveChanges(); return(mainProductionOrder); }
public DemandProviderProductionOrder CreateProviderProductionOrder(IDemandToProvider demand, ProductionOrder productionOrder, decimal amount) { var dppo = new DemandProviderProductionOrder() { ArticleId = demand.ArticleId, Quantity = amount, ProductionOrderId = productionOrder.Id, DemandRequesterId = demand.DemandRequesterId, }; Add(dppo); SaveChanges(); return(dppo); }
public DemandProviderProductionOrder CreateDemandProviderProductionOrder(IDemandToProvider demand, ProductionOrder productionOrder, decimal amount) { var demandProviderProductionOrder = new DemandProviderProductionOrder() { Quantity = amount, Article = demand.Article, ArticleId = demand.ArticleId, ProductionOrderId = productionOrder.Id, DemandRequesterId = demand.Id }; Demands.Add(demandProviderProductionOrder); if (productionOrder.DemandProviderProductionOrders == null) { productionOrder.DemandProviderProductionOrders = new List <DemandProviderProductionOrder>(); } productionOrder.DemandProviderProductionOrders.Add(demandProviderProductionOrder); SaveChanges(); return(demandProviderProductionOrder); }
public void AssignProductionOrderToDemandProvider(ProductionOrder productionOrder, DemandProviderProductionOrder provider) { if (productionOrder.DemandProviderProductionOrders == null) { productionOrder.DemandProviderProductionOrders = new List <DemandProviderProductionOrder>(); } if (!productionOrder.DemandProviderProductionOrders.Contains(provider)) { productionOrder.DemandProviderProductionOrders.Add(provider); } Update(provider); SaveChanges(); }