source: FarmatikoServices/Services/HealthcareWorkerService.cs@ 63d885e

Last change on this file since 63d885e was c406ae5, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago

Update Models, Repos, Services and Controllers

  • Property mode set to 100644
File size: 1.4 KB
Line 
1using FarmatikoData.FarmatikoRepoInterfaces;
2using FarmatikoData.Models;
3using FarmatikoServices.FarmatikoServiceInterfaces;
4using System;
5using System.Linq;
6using System.Threading.Tasks;
7
8namespace FarmatikoServices.Services
9{
10 public class HealthcareWorkerService : IHealthcareWorkerService
11 {
12 private IHealthcareWorkerRepository _healthcareWorkerRepo;
13 public HealthcareWorkerService(IHealthcareWorkerRepository healthcareWorkerRepo)
14 {
15 _healthcareWorkerRepo = healthcareWorkerRepo;
16 }
17 public async void Add(HealthcareWorkers healthcareWorker)
18 {
19 if (healthcareWorker != null)
20 await Task.Run(() => _healthcareWorkerRepo.Add(healthcareWorker));
21 else throw new Exception("Can't add, healthcare worker is null");
22 }
23
24 public async Task<IQueryable<HealthcareWorkers>> GetAll()
25 {
26 var healthCareWorkers = await Task.Run(() => _healthcareWorkerRepo.GetAll());
27 if (healthCareWorkers != null)
28 return healthCareWorkers;
29 return null;
30 }
31
32 public async void Remove(HealthcareWorkers healthcareWorker)
33 {
34 if (healthcareWorker != null)
35 await Task.Run(() => _healthcareWorkerRepo.Remove(healthcareWorker));
36 else throw new Exception("Can't Remove healthcare worker is null");
37 }
38 }
39}
Note: See TracBrowser for help on using the repository browser.