public ScheduleController() { //Let's be sure that every repo is using the same DbContext repo = new ScheduleRepository(context); doctorFacilityRepo = new DoctorFacilityRepository(context); doctorRepo = new DoctorRepository(context); facilityRepo = new FacilityRepository(context); doctorServiceRepo = new ForeignDoctorServiceRepository(context); client = new DpApi(AppSettings.ClientId, AppSettings.ClientSecret, (Locale)AppSettings.Locale); scheduleManager = new ScheduleManager(context, client); }
public MappingController() { var db = new HospitalContext(); client = new DpApi(AppSettings.ClientId, AppSettings.ClientSecret, (Locale)AppSettings.Locale); scheduleManager = new ScheduleManager(db, client); repo = new DoctorMappingRepository(db); addressRepo = new ForeignAddressRepository(db); doctorFacilityRepo = new DoctorFacilityRepository(db); doctorServiceRepo = new ForeignDoctorServiceRepository(db); }
private static void ImportDoctorServices(ForeignDoctorServiceRepository doctorServiceRepo, DPDoctor dpDoctor, ForeignDoctor foreignDoctor, List <DoctorService> doctorServices) { if (doctorServices == null) { return; } foreach (var doctorService in doctorServices) { var foreignDoctorService = new ForeignDoctorService() { Id = doctorService.Id, Name = doctorService.Name, PriceMax = doctorService.PriceMax, PriceMin = doctorService.PriceMin, ServiceId = doctorService.ServiceId, ForeignDoctorId = foreignDoctor.Id }; doctorServiceRepo.InsertOrUpdate(foreignDoctorService); } }
static void Main(string[] args) { string clientId = AppSettings.ClientId; string clientSecret = AppSettings.ClientSecret; string locale = AppSettings.Locale; bool shouldExit = false; HospitalContext myDb = new HospitalContext(); var facilityRepo = new ForeignFacilityRepository(myDb); var doctorRepo = new ForeignDoctorRepository(myDb); var addressRepo = new ForeignAddressRepository(myDb); var specializationRepo = new ForeignSpecializationRepository(myDb); var doctorServiceRepo = new ForeignDoctorServiceRepository(myDb); var client = new DpApi(clientId, clientSecret, (Locale)locale); var facilities = client.GetFacilities(); foreach (var facility in facilities) { Console.WriteLine($"IMPORTING FACILITY: {facility.Name}\n"); var foreignFacility = new ForeignFacility() { Id = facility.Id, Name = facility.Name }; facilityRepo.InsertOrUpdate(foreignFacility); var dpDoctors = new List <DPDoctor>(client.GetDoctors(facility.Id, true)); Console.WriteLine("DOCTORS:"); foreach (var dpDoctor in dpDoctors) { Console.WriteLine($"-> {dpDoctor.Name} {dpDoctor.Surname} (ID:{dpDoctor.Id})"); var foreignDoctor = new ForeignDoctor() { Id = dpDoctor.Id, Name = dpDoctor.Name, Surname = dpDoctor.Surname }; var tempDoctor = client.GetDoctor(facility.Id, dpDoctor.Id); Console.WriteLine("---> IMPORTING SPECIZALIZATIONS"); ImportSpecializations(specializationRepo, tempDoctor, foreignDoctor); var addresses = client.GetAddresses(facility.Id, dpDoctor.Id); Console.WriteLine("---> IMPORTING ADDRESSES"); ImportAddresses(addressRepo, dpDoctor, foreignFacility, foreignDoctor, addresses); var doctorServices = client.GetDoctorServices(facility.Id, dpDoctor.Id); Console.WriteLine("---> IMPORTING DOCTOR SERVICES"); ImportDoctorServices(doctorServiceRepo, dpDoctor, foreignDoctor, doctorServices); doctorRepo.InsertOrUpdate(foreignDoctor); Console.WriteLine(); } } doctorRepo.Save(); Console.WriteLine("DONE"); if (shouldExit == false) { Console.ReadLine(); } }