public async Task <Medic> GetMedicById(Guid id) { try { //_ = Task.Run(async () => //{ _logger.Debug("Medico traido correctamente"); //}); Medic med = await _medicRepository.GetById(id); return(med); } catch (Exception ex) { _logger.Error(ex.Message, ex); return(new Medic()); } }
public void AddTreatment(Guid appointmentId, Guid clientId, Guid medicId, Guid equipmentId, Guid medicationId, int equipmentUsageTime, int medicationQuantityUsed, string diagnosis ) { var appointment = appointmentRepository.GetAppointmentByID(appointmentId); var client = clientRepository.GetById(clientId); var medic = medicRepository.GetById(medicId); var equipment = equipmentTypeRepository.GetEquipmentById(equipmentId); var medication = medicationTypeRepository.GetMedicationById(medicationId); var treatment = treatmentRepository.Add(new Treatment() { Id = Guid.NewGuid(), Medic = medic, Client = client, Diagnosis = diagnosis, Equipments_Treatment = new List <Equipment_Treatment>(), Medications_Treatment = new List <Medication_Treatment>() }); var equipment_treatment = equipment_TreatmentRepository.Add(new Equipment_Treatment { Id = Guid.NewGuid(), UsageTime = equipmentUsageTime, }); var medication_treatment = medication_TreatmentRepository.Add(new Medication_Treatment { Id = Guid.NewGuid(), QuantityUsed = medicationQuantityUsed }); equipment.Equipment_Treatments.Add(equipment_treatment); equipmentTypeRepository.Update(equipment); medication.Medication_Treatments.Add(medication_treatment); medicationTypeRepository.Update(medication); treatment.Medications_Treatment.Add(medication_treatment); treatment.Equipments_Treatment.Add(equipment_treatment); treatmentRepository.Update(treatment); appointment.Treatment = treatment; appointmentRepository.Update(appointment); }