Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public async Task<List<Database.Models.Caregiver>> GetCaregivers()
- {
- await SEMAPHORE.WaitAsync();
- try
- {
- List<Database.Models.Caregiver> caregivers = await _dbConnection.QueryAsync<Database.Models.Caregiver>("select * from Caregiver where CircleId = (select Patient.CircleId from Profile inner join Patient ON Profile.ProfileId = Patient.ProfileId)");
- return caregivers;
- }
- catch (Exception)
- {
- return null;
- }
- finally
- {
- SEMAPHORE.Release();
- }
- }
- public async Task<List<Database.Models.Patient>> GetPatients()
- {
- await SEMAPHORE.WaitAsync();
- try
- {
- List<Database.Models.Patient> patients = await _dbConnection.QueryAsync<Database.Models.Patient>("select * from Patient where CircleId != (select Patient.CircleId from Profile inner join Patient ON Profile.ProfileId = Patient.ProfileId)");
- return patients;
- }
- catch (Exception)
- {
- return null;
- }
- finally
- {
- SEMAPHORE.Release();
- }
- }
- public async Task AddOrUpdatePatient(Database.Models.Patient patient)
- {
- await SEMAPHORE.WaitAsync();
- try
- {
- int rowsAffected = await _dbConnection.UpdateAsync(patient);
- if (rowsAffected == 0)
- {
- await _dbConnection.InsertAsync(patient);
- }
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine($"PyxDatabase.AddOrUpdatePatient() Exception: { ex }");
- }
- finally
- {
- SEMAPHORE.Release();
- }
- }
- public async Task<List<Database.Models.Patient>> GetCaregiversPatients()
- {
- await SEMAPHORE.WaitAsync();
- try
- {
- List<Database.Models.Patient> patients = await _dbConnection.QueryAsync<Database.Models.Patient>("select * from Patient where CircleId = (select Patient.CircleId from Profile inner join Patient ON Profile.ProfileId != Patient.ProfileId)");
- return patients;
- }
- catch (Exception)
- {
- return null;
- }
- finally
- {
- SEMAPHORE.Release();
- }
- }
- public async Task<int> GetCurrentUserProfileCircleId()
- {
- await SEMAPHORE.WaitAsync();
- try
- {
- int circleId = await _dbConnection.ExecuteAsync("select Patient.CircleId from Profile inner join Patient ON Profile.ProfileId = Patient.ProfileId");
- return circleId;
- }
- catch (Exception)
- {
- return -1;
- }
- finally
- {
- SEMAPHORE.Release();
- }
- }
Add Comment
Please, Sign In to add comment