private void PhotoProcess(CompleteInput input, WorkOrderBill bill, CompleteOutput output) { if (input.Photos != null) { foreach (var photo in input.Photos) { var newPhoto = bill.Photos.FirstOrDefault(x => x.FilePath == photo.FilePath); if (newPhoto == null) { //新增分录 newPhoto = new WorkOrderPhoto(); newPhoto.Bill = bill; newPhoto.FilePath = photo.FilePath; _workOrderPhotoRepository.Insert(newPhoto); } } } //删除照片 for (int i = bill.Photos.Count - 1; i >= 0; i--) { WorkOrderPhoto photo = bill.Photos.ElementAt(i); if (input.Photos == null) { //删除分录 _workOrderPhotoRepository.Delete(photo); i--; } else { var photoInput = input.Photos.FirstOrDefault(x => x.FilePath == photo.FilePath); if (photoInput == null) { //删除分录 _workOrderPhotoRepository.Delete(photo); i--; } } } }
private void PhotoProcess(ReportInput input, WorkOrderBill bill) { for (int i = bill.Photos.Count - 1; i >= 0; i--) { WorkOrderPhoto photo = bill.Photos.ElementAt(i); //删除分录 _workOrderPhotoRepository.Delete(photo); // i--; } if (input.Photos == null) { return; } foreach (var photo in input.Photos) { var newPhoto = new WorkOrderPhoto() { FilePath = photo, Bill = bill }; _workOrderPhotoRepository.Insert(newPhoto); } }