Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • FarmatikoServices/Services/HealthcareWorkerService.cs

    ra55ef91 rc406ae5  
    44using System;
    55using System.Linq;
     6using System.Threading.Tasks;
    67
    78namespace FarmatikoServices.Services
     
    1415            _healthcareWorkerRepo = healthcareWorkerRepo;
    1516        }
    16         public void Add(HealthcareWorkers healthcareWorker)
     17        public async void Add(HealthcareWorkers healthcareWorker)
    1718        {
    18             try
    19             {
    20                 if (healthcareWorker != null)
    21                     _healthcareWorkerRepo.Add(healthcareWorker);
    22             }
    23             catch (Exception e)
    24             {
    25                 e = new Exception("Can't Add healthcare worker is null");
    26                 throw e;
    27             }
     19            if (healthcareWorker != null)
     20                await Task.Run(() => _healthcareWorkerRepo.Add(healthcareWorker));
     21            else throw new Exception("Can't add, healthcare worker is null");
    2822        }
    2923
    30         public IQueryable<HealthcareWorkers> GetAll()
     24        public async Task<IQueryable<HealthcareWorkers>> GetAll()
    3125        {
    32             return _healthcareWorkerRepo.GetAll();
     26            var healthCareWorkers = await Task.Run(() => _healthcareWorkerRepo.GetAll());
     27            if (healthCareWorkers != null)
     28                return healthCareWorkers;
     29            return null;
    3330        }
    3431
    35         public void Remove(HealthcareWorkers healthcareWorker)
     32        public async void Remove(HealthcareWorkers healthcareWorker)
    3633        {
    37             try
    38             {
    39                 if (healthcareWorker != null)
    40                     _healthcareWorkerRepo.Remove(healthcareWorker);
    41             }
    42             catch (Exception e)
    43             {
    44                 e = new Exception("Can't Remove healthcare worker is null");
    45                 throw e;
    46             }
     34            if (healthcareWorker != null)
     35                await Task.Run(() => _healthcareWorkerRepo.Remove(healthcareWorker));
     36            else throw new Exception("Can't Remove healthcare worker is null");
    4737        }
    4838    }
Note: See TracChangeset for help on using the changeset viewer.