public List <ReferralDto> GetAll() { List <ReferralDto> allReferrals = new List <ReferralDto>(); _dbContext.Referrals.ToList().ForEach(referral => allReferrals.Add(ReferralAdapter.ReferralToReferralDto(referral))); return(allReferrals); }
public void SetAppointmentsReferralDeleted(Appointment appointment) { if (_referralService.GetAppointmentsReferral(appointment) != null) { Referral referal1 = ReferralAdapter.ReferralDtoToReferral(_referralService.GetAppointmentsReferral(appointment)); Referral referal2 = _dbContext.Referrals.SingleOrDefault(referral => referral.Id == referal1.Id); referal2.IsDeleted = true; _dbContext.SaveChanges(); } }
public ReferralDto GetById(int referralId) { Referral myReferral = _dbContext.Referrals.SingleOrDefault(referral => referral.Id == referralId); if (myReferral == null) { return(null); } return(ReferralAdapter.ReferralToReferralDto(myReferral)); }
public ReferralDto GetAppointmentsReferral(Appointment appointment) { Referral myReferral = _dbContext.Referrals.SingleOrDefault(referral => referral.PatientId == appointment.Patient.Id && referral.SpecialistId == appointment.DoctorId); if (myReferral == null) { return(null); } return(ReferralAdapter.ReferralToReferralDto(myReferral)); }
public ReferralDto Add(ReferralDto referralDto) { if (referralDto == null) { return(null); } Referral referral = ReferralAdapter.ReferralDtoToReferral(referralDto); GivePatientReferral(_dbContext.Patients.SingleOrDefault(patient => patient.Id == referralDto.PatientId), referral); _dbContext.Doctors.SingleOrDefault(doctor => doctor.Id == referralDto.SpecialistId).Referrals.Add(referral); _dbContext.Referrals.Add(referral); _dbContext.SaveChanges(); return(referralDto); }