Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • FarmatikoServices/Services/HealthcareWorkerService.cs

    rc406ae5 ra55ef91  
    44using System;
    55using System.Linq;
    6 using System.Threading.Tasks;
    76
    87namespace FarmatikoServices.Services
     
    1514            _healthcareWorkerRepo = healthcareWorkerRepo;
    1615        }
    17         public async void Add(HealthcareWorkers healthcareWorker)
     16        public void Add(HealthcareWorkers healthcareWorker)
    1817        {
    19             if (healthcareWorker != null)
    20                 await Task.Run(() => _healthcareWorkerRepo.Add(healthcareWorker));
    21             else throw new Exception("Can't add, healthcare worker is null");
     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            }
    2228        }
    2329
    24         public async Task<IQueryable<HealthcareWorkers>> GetAll()
     30        public IQueryable<HealthcareWorkers> GetAll()
    2531        {
    26             var healthCareWorkers = await Task.Run(() => _healthcareWorkerRepo.GetAll());
    27             if (healthCareWorkers != null)
    28                 return healthCareWorkers;
    29             return null;
     32            return _healthcareWorkerRepo.GetAll();
    3033        }
    3134
    32         public async void Remove(HealthcareWorkers healthcareWorker)
     35        public void Remove(HealthcareWorkers healthcareWorker)
    3336        {
    34             if (healthcareWorker != null)
    35                 await Task.Run(() => _healthcareWorkerRepo.Remove(healthcareWorker));
    36             else throw new Exception("Can't Remove healthcare worker is null");
     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            }
    3747        }
    3848    }
Note: See TracChangeset for help on using the changeset viewer.