Example #1
0
 public void DeleteAircraft(AircraftDTO dto)
 {
     if (dto == null)
     {
         throw new ArgumentException("参数为空!");
     }
     Aircraft delAircraft = _aircraftRepository.Get(dto.AircraftId);
     //获取需要删除的对象。
     if (delAircraft != null)
     {
         _aircraftRepository.DeleteAircraft(delAircraft); //删除实际飞机。
     }
 }
Example #2
0
        public void ModifyAircraft(AircraftDTO dto)
        {
            //获取相关数据
            AircraftType aircraftType = _aircraftTypeRepository.Get(dto.AircraftTypeId);
            Airlines airlines = _airlinesRepository.Get(dto.AirlinesId);
            ActionCategory importCategory = _actionCategoryRepository.Get(dto.ImportCategoryId);
            Supplier supplier = _supplierRepository.Get(dto.SupplierId);

            //获取
            Aircraft updateAircraft = _aircraftRepository.Get(dto.AircraftId);
            if (updateAircraft != null)
            {
                //更新实际飞机
                updateAircraft.SetAircraftType(aircraftType);
                updateAircraft.SetAirlines(airlines);
                updateAircraft.SetCarryingCapacity(dto.CarryingCapacity);
                updateAircraft.SetExportDate(dto.ExportDate);
                updateAircraft.SetFactoryDate(dto.FactoryDate);
                updateAircraft.SetImportCategory(importCategory);
                updateAircraft.SetImportDate(dto.ImportDate);
                updateAircraft.SetOperation();
                updateAircraft.SetRegNumber(dto.RegNumber);
                updateAircraft.SetSeatingCapacity(dto.SeatingCapacity);
                updateAircraft.SetSerialNumber(dto.SerialNumber);
                updateAircraft.SetSupplier(supplier);

                //更新商业数据历史:
                List<AircraftBusinessDTO> dtoAircraftBusinesses = dto.AircraftBusinesses;
                ICollection<AircraftBusiness> aircraftBusinesses = updateAircraft.AircraftBusinesses;
                DataHelper.DetailHandle(dtoAircraftBusinesses.ToArray(),
                    aircraftBusinesses.ToArray(),
                    c => c.AircraftBusinessId, p => p.Id,
                    i => InsertAircraftBusiness(updateAircraft, i),
                    UpdateAircraftBusiness,
                    d => _aircraftRepository.RemoveAircraftBusiness(d));

                //更新运营权历史:
                List<OperationHistoryDTO> dtoOperationHistories = dto.OperationHistories;
                ICollection<OperationHistory> operationHistories = updateAircraft.OperationHistories;
                DataHelper.DetailHandle(dtoOperationHistories.ToArray(),
                    operationHistories.ToArray(),
                    c => c.OperationHistoryId, p => p.Id,
                    i => InsertOperationHistory(updateAircraft, i),
                    UpdateOperationHistory,
                    d => _aircraftRepository.RemoveOperationHistory(d));

                //更新所有权历史:
                List<OwnershipHistoryDTO> dtoOwnershipHistories = dto.OwnershipHistories;
                ICollection<OwnershipHistory> ownershipHistories = updateAircraft.OwnershipHistories;
                DataHelper.DetailHandle(dtoOwnershipHistories.ToArray(),
                    ownershipHistories.ToArray(),
                    c => c.OwnershipHistoryId, p => p.Id,
                    i => InsertOwnershipHistory(updateAircraft, i),
                    UpdateOwnershipHistory,
                    d => _aircraftRepository.RemoveOwnershipHistory(d));

                //更新飞机配置历史:
                List<AcConfigHistoryDTO> dtoAcConfigHistories = dto.AcConfigHistories;
                ICollection<AcConfigHistory> acConfigHistories = updateAircraft.AcConfigHistories;
                DataHelper.DetailHandle(dtoAcConfigHistories.ToArray(),
                    acConfigHistories.ToArray(),
                    c => c.Id, p => p.Id,
                    i => InsertAcConfigHistory(updateAircraft, i),
                    UpdateAcConfigHistory,
                    d => _aircraftRepository.RemoveAcConfigHistory(d));
            }
            _aircraftRepository.Modify(updateAircraft);
        }
Example #3
0
        public void InsertAircraft(AircraftDTO dto)
        {
            //获取相关数据
            AircraftType aircraftType = _aircraftTypeRepository.Get(dto.AircraftTypeId);
            Airlines airlines = _airlinesRepository.Get(dto.AirlinesId);
            ActionCategory importCategory = _actionCategoryRepository.Get(dto.ImportCategoryId);
            Supplier supplier = _supplierRepository.Get(dto.SupplierId);

            //创建新的实际飞机
            Aircraft newAircraft = AircraftFactory.CreateAircraft();
            newAircraft.ChangeCurrentIdentity(dto.AircraftId);
            newAircraft.SetAircraftType(aircraftType);
            newAircraft.SetAirlines(airlines);
            newAircraft.SetCarryingCapacity(dto.CarryingCapacity);
            newAircraft.SetExportDate(dto.ExportDate);
            newAircraft.SetFactoryDate(dto.FactoryDate);
            newAircraft.SetImportCategory(importCategory);
            newAircraft.SetImportDate(dto.ImportDate);
            newAircraft.SetOperation();
            newAircraft.SetRegNumber(dto.RegNumber);
            newAircraft.SetSeatingCapacity(dto.SeatingCapacity);
            newAircraft.SetSerialNumber(dto.SerialNumber);
            newAircraft.SetSupplier(supplier);

            //添加商业数据历史
            dto.AircraftBusinesses.ToList().ForEach(line => InsertAircraftBusiness(newAircraft, line));

            //添加运营权历史
            dto.OperationHistories.ToList().ForEach(line => InsertOperationHistory(newAircraft, line));

            //添加所有权历史
            dto.OwnershipHistories.ToList().ForEach(line => InsertOwnershipHistory(newAircraft, line));

            //添加飞机配置历史
            dto.AcConfigHistories.ToList().ForEach(line => InsertAcConfigHistory(newAircraft, line));

            _aircraftRepository.Add(newAircraft);
        }