public void MapToEntity(TreatmentReport treatmentReport, TreatmentReportEntity treatmentReportEntity) { if (treatmentReportEntity != null && treatmentReport != null) { treatmentReportEntity.Id = treatmentReport.Id; treatmentReportEntity.Conclusion = treatmentReport.Conclusion; treatmentReportEntity.Comment = treatmentReport.Comment; if (treatmentReport.CurrentTreatment != null) { var treatmentEntity = new TreatmentEntity(); treatmentMapper.MapToEntity(treatmentReport.CurrentTreatment, treatmentEntity); treatmentReportEntity.TreatmentId = treatmentEntity.Id; } if (treatmentReport.Medicines != null && treatmentReport.Medicines.Any()) { var medicineRepository = MedicineRepository.GetInstance(); foreach (var medicine in treatmentReport.Medicines) { var medicineEntity = medicineRepository.GetItemById(medicine.Id); treatmentReportEntity.Medicines.Add(medicineEntity); } } } }
public void MapToEntity(Operation operation, OperationEntity operationEntity) { if (operation != null && operationEntity != null) { operationEntity.Id = operation.Id; operationEntity.TreatmentId = operation.TreatmentId; if (operation.CurrentTypeOperation != null) { var typeOperationEntity = new TypeOperationEntity(); typeOperationMapper.MapToEntity(operation.CurrentTypeOperation, typeOperationEntity); operationEntity.TypeOperationId = typeOperationEntity.Id; } if (operation.Medicines.Any()) { var medcicineRepository = MedicineRepository.GetInstance(); foreach (var medicine in operation.Medicines) { var medicineEntity = medcicineRepository.GetItemById(medicine.Id); operationEntity.Medicines.Add(medicineEntity); } } } }
public MedicineService() { medicineRepository = MedicineRepository.GetInstance(); medicineMapper = new MedicineMapper(); }