public void DeleteAircraftLeaseReception(AircraftLeaseReceptionDTO dto)
 {
     if (dto == null)
     {
         throw new ArgumentException("参数为空!");
     }
     Reception delAircraftLeaseReception = _receptionRepository.Get(dto.AircraftLeaseReceptionId);
     //获取需要删除的对象。
     if (delAircraftLeaseReception != null)
     {
         _receptionRepository.DeleteReception(delAircraftLeaseReception); //删除租赁飞机接收项目。
     }
 }
Beispiel #2
0
 public void TesInsertAircraftLeaseReception()
 {
     // Arrange
     var service = UniContainer.Resolve<IAircraftLeaseReceptionAppService>();
     //Data
     var reception = new AircraftLeaseReceptionDTO
     {
         ReceptionNumber = "20131209001",
         Description = "miaoshu",
         StartDate = DateTime.Now,
         EndDate = DateTime.Now,
         CreateDate = DateTime.Now,
         IsClosed = false,
         CloseDate = DateTime.Now,
         SupplierName = "空客",
         SupplierId = 2,
         ReceptionLines = new List<AircraftLeaseReceptionLineDTO>
         {
             new AircraftLeaseReceptionLineDTO
             {
                 MSN = "1231",
                 ReceivedAmount = 123,
                 AcceptedAmount = 121,
                 IsCompleted = false,
                 Note = "note",
                 DeliverDate = DateTime.Now,
                 DeliverPlace = "xiamen",
                 ContractAircraftId = 2,
             }
         },
         ReceptionSchedules = new List<ReceptionScheduleDTO>
         {
             new ReceptionScheduleDTO
             {
                 Subject = "123",
                 Body = "123453",
                 Importance = "高级别",
                 Start = new DateTime(2013, 09, 01),
                 End = DateTime.Now,
                 Group = "机务组",
                 Tempo = "已完成",
             }
         },
     };
     var result = service.GetAircraftLeaseReceptions();
     //service.InsertAircraftLeaseReception(reception);
     // Act
     // Assert
     Assert.IsTrue(result.Any());
 }
        public void InsertAircraftLeaseReception(AircraftLeaseReceptionDTO dto)
        {
            //获取供应商
            Supplier supplier = _supplierRepository.Get(dto.SupplierId);

            //创建接机项目
            AircraftLeaseReception newReception = ReceptionFactory.CreateAircraftLeaseReception(dto.StartDate,
                dto.EndDate, dto.SourceId,
                dto.Description);

            // TODO:设置接机编号,如果当天的记录被删除过,流水号seq可能会重复
            DateTime date = DateTime.Now.Date;
            int seq = _receptionRepository.GetFiltered(t => t.CreateDate > date).Count() + 1;
            newReception.SetReceptionNumber(seq);

            //设置供应商
            newReception.SetSupplier(supplier);

            //设置接机的状态
            newReception.SetStatus(ReceptionStatus.开始);

            //添加接机行
            dto.ReceptionLines.ToList().ForEach(line => InsertReceptionLine(newReception, line));
            //添加相关的接机日程
            dto.ReceptionSchedules.ToList().ForEach(scheduel => InsertReceptionSchedule(newReception, scheduel));

            _receptionRepository.Add(newReception);
        }
        public void ModifyAircraftLeaseReception(AircraftLeaseReceptionDTO dto)
        {
            //获取供应商
            Supplier supplier = _supplierRepository.Get(dto.SupplierId);

            //获取需要更新的对象
            var updateReception = _receptionRepository.Get(dto.AircraftLeaseReceptionId) as AircraftLeaseReception;

            if (updateReception != null)
            {
                //更新主表:
                updateReception.SetReceptionNumber(dto.ReceptionNumber);
                updateReception.Description = dto.Description;
                updateReception.StartDate = dto.StartDate;
                updateReception.EndDate = dto.EndDate;
                updateReception.SetSupplier(supplier);
                updateReception.SetStatus((ReceptionStatus) dto.Status);
                updateReception.SourceId = dto.SourceId;

                //更新接机行:
                List<AircraftLeaseReceptionLineDTO> dtoReceptionLines = dto.ReceptionLines;
                ICollection<ReceptionLine> receptionLines = updateReception.ReceptionLines;
                DataHelper.DetailHandle(dtoReceptionLines.ToArray(),
                    receptionLines.OfType<AircraftLeaseReceptionLine>().ToArray(),
                    c => c.AircraftLeaseReceptionLineId, p => p.Id,
                    i => InsertReceptionLine(updateReception, i),
                    UpdateReceptionLine,
                    d => _receptionRepository.RemoveReceptionLine(d));
                //更新交付日程:
                List<ReceptionScheduleDTO> dtoReceptionSchedules = dto.ReceptionSchedules;
                ICollection<ReceptionSchedule> receptionSchedules = updateReception.ReceptionSchedules;
                DataHelper.DetailHandle(dtoReceptionSchedules.ToArray(),
                    receptionSchedules.ToArray(),
                    c => c.ReceptionScheduleId, p => p.Id,
                    i => InsertReceptionSchedule(updateReception, i),
                    UpdateReceptionSchedule,
                    d => _receptionRepository.RemoveReceptionSchedule(d));
            }
            _receptionRepository.Modify(updateReception);
        }