示例#1
0
        /// <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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
 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();
 }