Esempio n. 1
0
        /// <summary>
        ///     添加发动机购买订单行
        /// </summary>
        /// <param name="price">单价</param>
        /// <param name="amount">数量</param>
        /// <param name="discount">折扣</param>
        /// <param name="delivery">预计交付日期</param>
        /// <returns>发动机购买订单行</returns>
        public EnginePurchaseOrderLine AddNewEnginePurchaseOrderLine(decimal price, int amount, decimal discount,
            DateTime delivery)
        {
            var enginePurchaseOrderLine = new EnginePurchaseOrderLine();
            enginePurchaseOrderLine.GenerateNewIdentity();

            enginePurchaseOrderLine.OrderId = Id;
            enginePurchaseOrderLine.UnitPrice = price;
            enginePurchaseOrderLine.Amount = amount;
            enginePurchaseOrderLine.Discount = discount;
            enginePurchaseOrderLine.EstimateDeliveryDate = delivery;

            OrderLines.Add(enginePurchaseOrderLine);

            return enginePurchaseOrderLine;
        }
Esempio n. 2
0
        /// <summary>
        ///     更新订单行
        /// </summary>
        /// <param name="line">订单行DTO</param>
        /// <param name="orderLine">订单行</param>
        private void UpdateOrderLine(EnginePurchaseOrderLineDTO line, EnginePurchaseOrderLine orderLine)
        {
            // 获取飞机物料机型
            var material =
                _materialRepository.GetFiltered(m => m.Id == line.EngineMaterialId)
                    .OfType<EngineMaterial>()
                    .FirstOrDefault();
            var pnReg = _pnRegRepository.GetFiltered(p => p.Pn == material.Pn).FirstOrDefault();
            if (material == null)
            {
                throw new ArgumentException("未能获取飞机物料!");
            }

            // 更新订单行
            orderLine.UpdateOrderLine(line.UnitPrice, line.Amount, line.Discount, line.EstimateDeliveryDate);
            orderLine.SetEngineMaterial(line.EngineMaterialId);

            // 更新合同发动机
            var contractEngine = _contractEngineRepository.Get(orderLine.ContractEngineId);
            contractEngine.SetRankNumber(line.RankNumber);
            contractEngine.SetSerialNumber(line.SerialNumber);
            contractEngine.SetPart(pnReg);
        }