source: FarmatikoServices/Services/HealthcareWorkerService.cs@ 5d02859

Last change on this file since 5d02859 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
RevLine 
[a55ef91]1using FarmatikoData.FarmatikoRepoInterfaces;
[d2e69be]2using FarmatikoData.Models;
[e42f61a]3using FarmatikoServices.FarmatikoServiceInterfaces;
[d2e69be]4using System;
[a55ef91]5using System.Linq;
[c406ae5]6using System.Threading.Tasks;
[d2e69be]7
8namespace FarmatikoServices.Services
9{
10 public class HealthcareWorkerService : IHealthcareWorkerService
11 {
[e42f61a]12 private IHealthcareWorkerRepository _healthcareWorkerRepo;
13 public HealthcareWorkerService(IHealthcareWorkerRepository healthcareWorkerRepo)
[d2e69be]14 {
[e42f61a]15 _healthcareWorkerRepo = healthcareWorkerRepo;
[d2e69be]16 }
[c406ae5]17 public async void Add(HealthcareWorkers healthcareWorker)
[d2e69be]18 {
[c406ae5]19 if (healthcareWorker != null)
20 await Task.Run(() => _healthcareWorkerRepo.Add(healthcareWorker));
21 else throw new Exception("Can't add, healthcare worker is null");
[d2e69be]22 }
23
[c406ae5]24 public async Task<IQueryable<HealthcareWorkers>> GetAll()
[d2e69be]25 {
[c406ae5]26 var healthCareWorkers = await Task.Run(() => _healthcareWorkerRepo.GetAll());
27 if (healthCareWorkers != null)
28 return healthCareWorkers;
29 return null;
[d2e69be]30 }
[a55ef91]31
[c406ae5]32 public async void Remove(HealthcareWorkers healthcareWorker)
[a55ef91]33 {
[c406ae5]34 if (healthcareWorker != null)
35 await Task.Run(() => _healthcareWorkerRepo.Remove(healthcareWorker));
36 else throw new Exception("Can't Remove healthcare worker is null");
[a55ef91]37 }
[d2e69be]38 }
39}
Note: See TracBrowser for help on using the repository browser.