private ICollection <Doctor> getOpenSlotByDoctorPerGivenDate(ICollection <Doctor> doctorList, GetAppointmentSlotListRequest request, ICollection <int> doctorIdList = null) { var query = db.Appointments.Where(x => x.ConsultationTime.Value != null && x.ConsultationTime.Value == request.AppointmentDate); query = doctorIdList != null ? query = query.Where(x => doctorIdList.Contains(x.DoctorId)) : query.Where(x => x.DoctorId == request.DoctorId); var doctorAppointmentList = query.ToList(); var appointmentSlotList = db.AppointmentSlots.ToList(); var availableSolts = filterAvailableSolts(doctorAppointmentList, appointmentSlotList); return(doctorList.Select(x => new Doctor { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, SpecializedIn = x.SpecializedIn, DepartmentId = x.DepartmentId, OpenAppointmentSlots = getOpenSlotList(availableSolts, x.Id) }).ToList()); }
public ICollection <Doctor> GetAppointmentSlotList(GetAppointmentSlotListRequest request) { var doctorList = db.Doctors.Where(x => x.Id == request.DoctorId).ToList(); return(getOpenSlotByDoctorPerGivenDate(doctorList, request)); }