Esempio n. 1
0
        /// <summary>
        ///     创建飞机租赁订单
        /// </summary>
        /// <param name="version">版本</param>
        /// <param name="operatorName">经办人</param>
        /// <param name="orderDate">订单日期</param>
        /// <returns>飞机租赁订单</returns>
        public static AircraftLeaseOrder CreateAircraftLeaseOrder(int version,
            string operatorName, DateTime orderDate)
        {
            var aircraftLeaseOrder = new AircraftLeaseOrder
            {
                Version = version,
                OperatorName = operatorName,
                CreateDate = DateTime.Now,
                OrderDate = orderDate,
                IsValid = true
            };

            return aircraftLeaseOrder;
        }
Esempio n. 2
0
        /// <summary>
        ///     插入新订单行
        /// </summary>
        /// <param name="order">订单</param>
        /// <param name="dto">订单DTO</param>
        /// <param name="line">订单行DTO</param>
        /// <param name="importType">引进方式</param>
        /// <param name="supplierId">供应商ID</param>
        private void InsertOrderLine(AircraftLeaseOrder order, AircraftLeaseOrderDTO dto,
            AircraftLeaseOrderLineDTO line, ActionCategory importType, int supplierId)
        {
            // 获取飞机物料机型
            var material =
                _materialRepository.GetFiltered(m => m.Id == line.AircraftMaterialId)
                    .OfType<AircraftMaterial>()
                    .FirstOrDefault();
            if (material == null)
            {
                throw new ArgumentException("未能获取飞机物料!");
            }
            var aircraftTypeId = material.AircraftTypeId;

            // 添加订单行
            var orderLine = order.AddNewAircraftLeaseOrderLine(line.UnitPrice, line.Amount,
                line.Discount, line.EstimateDeliveryDate);
            orderLine.SetAircraftMaterial(line.AircraftMaterialId);

            // 创建或引用合同飞机
            var persist = _contractAircraftRepository.Get(line.ContractAircraftId) as LeaseContractAircraft;
            var contractAircraft = ContractAircraftFactory.CreateLeaseContractAircraft(dto.Name,
                line.RankNumber);
            contractAircraft.ChangeCurrentIdentity(line.ContractAircraftId);
            contractAircraft.SetAircraftType(aircraftTypeId);
            contractAircraft.SetImportCategory(importType);
            contractAircraft.SetCSCNumber(line.CSCNumber);
            contractAircraft.SetSerialNumber(line.SerialNumber);
            contractAircraft.SetSupplier(supplierId);
            contractAircraft.SetPlanAircraft(line.PlanAircraftID);
            if (persist == null)
            {
                orderLine.SetContractAircraft(contractAircraft);
            }
            else
            {
                orderLine.SetContractAircraft(persist);
                _contractAircraftRepository.Merge(persist, contractAircraft);
            }
        }