public void DeleteAirProgramming(AirProgrammingDTO dto)
 {
     if (dto == null)
     {
         throw new ArgumentException("参数为空!");
     }
     AirProgramming delAirProgramming = _airProgrammingRepository.Get(dto.Id);
     //获取需要删除的对象。
     if (delAirProgramming != null)
     {
         _airProgrammingRepository.DeleteAirProgramming(delAirProgramming); //删除航空公司五年规划。
     }
 }
        public void ModifyAirProgramming(AirProgrammingDTO dto)
        {
            IssuedUnit issuedUnit = _issuedUnitRepository.Get(dto.IssuedUnitId); //获取发文单位
            Programming programming = _programmingRepository.Get(dto.ProgrammingId); //获取规划期间

            //获取需要更新的对象
            AirProgramming updateAirProgramming = _airProgrammingRepository.Get(dto.Id);

            if (updateAirProgramming != null)
            {
                //更新主表:
                updateAirProgramming.SetDocument(dto.DocumentId, dto.DocName);
                updateAirProgramming.SetIssuedDate(dto.IssuedDate);
                updateAirProgramming.SetIssuedUnit(issuedUnit);
                updateAirProgramming.SetName(dto.Name);
                updateAirProgramming.SetNote(dto.Note);
                updateAirProgramming.SetProgramming(programming);

                //更新规划行:
                List<AirProgrammingLineDTO> dtoAirProgrammingLines = dto.AirProgrammingLines;
                ICollection<AirProgrammingLine> airProgrammingLines = updateAirProgramming.AirProgrammingLines;
                DataHelper.DetailHandle(dtoAirProgrammingLines.ToArray(),
                    airProgrammingLines.ToArray(),
                    c => c.Id, p => p.Id,
                    i => InsertAirProgrammingLine(updateAirProgramming, i),
                    UpdateAirProgrammingLine,
                    d => _airProgrammingRepository.RemoveAirProgrammingLine(d));
            }
            _airProgrammingRepository.Modify(updateAirProgramming);
        }
        public void InsertAirProgramming(AirProgrammingDTO dto)
        {
            IssuedUnit issuedUnit = _issuedUnitRepository.Get(dto.IssuedUnitId); //获取发文单位
            Programming programming = _programmingRepository.Get(dto.ProgrammingId); //获取规划期间

            //创建航空公司五年规划
            AirProgramming newAirProgramming = AirProgrammingFactory.CreateAirProgramming();
            newAirProgramming.SetDocument(dto.DocumentId, dto.DocName);
            newAirProgramming.SetIssuedDate(dto.IssuedDate);
            newAirProgramming.SetIssuedUnit(issuedUnit);
            newAirProgramming.SetName(dto.Name);
            newAirProgramming.SetNote(dto.Note);
            newAirProgramming.SetProgramming(programming);

            //添加规划行
            dto.AirProgrammingLines.ToList().ForEach(line => InsertAirProgrammingLine(newAirProgramming, line));

            _airProgrammingRepository.Add(newAirProgramming);
        }