1 | using FarmatikoData.FarmatikoRepoInterfaces;
|
---|
2 | using FarmatikoData.Models;
|
---|
3 | using FarmatikoServices.FarmatikoServiceInterfaces;
|
---|
4 | using System;
|
---|
5 | using System.Linq;
|
---|
6 | using System.Threading.Tasks;
|
---|
7 |
|
---|
8 | namespace FarmatikoServices.Services
|
---|
9 | {
|
---|
10 | public class Service : IService
|
---|
11 | {
|
---|
12 | private readonly IRepository _repository;
|
---|
13 | public Service(IRepository repository)
|
---|
14 | {
|
---|
15 | _repository = repository;
|
---|
16 | }
|
---|
17 |
|
---|
18 | //GET
|
---|
19 | public async Task<IQueryable<HealthcareWorkers>> GetAllWorkers()
|
---|
20 | {
|
---|
21 | var Workers = await _repository.GetAllWorkers();
|
---|
22 | return Workers;
|
---|
23 | }
|
---|
24 |
|
---|
25 | public async Task<IQueryable<HealthFacilities>> GetFacilities()
|
---|
26 | {
|
---|
27 | var Facilities = await _repository.GetFacilities();
|
---|
28 | return Facilities;
|
---|
29 | }
|
---|
30 |
|
---|
31 | public async Task<HealthFacilities> GetFacility(int id)
|
---|
32 | {
|
---|
33 | var Facility = await _repository.GetFacility(id);
|
---|
34 | return Facility;
|
---|
35 | }
|
---|
36 |
|
---|
37 | public async Task<Medicine> GetMedicine(int id)
|
---|
38 | {
|
---|
39 | var Medicine = await _repository.GetMedicine(id);
|
---|
40 | return Medicine;
|
---|
41 | }
|
---|
42 |
|
---|
43 | public async Task<IQueryable<Medicine>> GetMedicines()
|
---|
44 | {
|
---|
45 | var Medicines = await _repository.GetMedicines();
|
---|
46 | return Medicines;
|
---|
47 | }
|
---|
48 |
|
---|
49 | public async Task<Pandemic> GetPandemic()
|
---|
50 | {
|
---|
51 | var Pandemic = await _repository.GetPandemic();
|
---|
52 | return Pandemic;
|
---|
53 | }
|
---|
54 |
|
---|
55 | public async Task<IQueryable<Pharmacy>> GetPharmacies()
|
---|
56 | {
|
---|
57 | var Pharmacies = await _repository.GetPharmacies();
|
---|
58 | return Pharmacies;
|
---|
59 | }
|
---|
60 |
|
---|
61 | public async Task<Pharmacy> GetPharmacy(int id)
|
---|
62 | {
|
---|
63 | var Pharmacy = await _repository.GetPharmacy(id);
|
---|
64 | return Pharmacy;
|
---|
65 | }
|
---|
66 |
|
---|
67 | public async Task<HealthcareWorkers> GetWorker(int id)
|
---|
68 | {
|
---|
69 | var Worker = await _repository.GetWorker(id);
|
---|
70 | return Worker;
|
---|
71 | }
|
---|
72 |
|
---|
73 | public async Task<IQueryable<HealthFacilities>> SearchFacilities(string query)
|
---|
74 | {
|
---|
75 | var SearchQuery = await _repository.SearchFacilities(query);
|
---|
76 | return SearchQuery;
|
---|
77 | }
|
---|
78 |
|
---|
79 | public async Task<IQueryable<Medicine>> SearchMedicines(string query)
|
---|
80 | {
|
---|
81 | var SearchQuery = await _repository.SearchMedicines(query);
|
---|
82 | return SearchQuery;
|
---|
83 | }
|
---|
84 |
|
---|
85 | public async Task<IQueryable<Pharmacy>> SearchPharmacies(string query)
|
---|
86 | {
|
---|
87 | var SearchQuery = await _repository.SearchPharmacies(query);
|
---|
88 | return SearchQuery;
|
---|
89 | }
|
---|
90 |
|
---|
91 | public async Task<IQueryable<HealthcareWorkers>> SearchWorkers(string query)
|
---|
92 | {
|
---|
93 | var SearchQuery = await _repository.SearchWorkers(query);
|
---|
94 | return SearchQuery;
|
---|
95 | }
|
---|
96 |
|
---|
97 |
|
---|
98 | //POST (ADD NEW OBJECTS)
|
---|
99 | public Task AddFacility(HealthFacilities healthFacilities)
|
---|
100 | {
|
---|
101 | if (healthFacilities != null)
|
---|
102 | _repository.AddFacility(healthFacilities);
|
---|
103 | throw new Exception("Facility is null");
|
---|
104 | }
|
---|
105 |
|
---|
106 | public Task AddMedicines(Medicine medicine)
|
---|
107 | {
|
---|
108 | if (medicine != null)
|
---|
109 | _repository.AddMedicines(medicine);
|
---|
110 | throw new Exception("Medicine is null");
|
---|
111 | }
|
---|
112 |
|
---|
113 | public Task AddPandemic(Pandemic pandemic)
|
---|
114 | {
|
---|
115 | if (pandemic != null)
|
---|
116 | _repository.AddPandemic(pandemic);
|
---|
117 | throw new Exception("Pandemic is null");
|
---|
118 | }
|
---|
119 |
|
---|
120 | public Task AddPharmacy(Pharmacy pharmacy)
|
---|
121 | {
|
---|
122 | if (pharmacy != null)
|
---|
123 | _repository.AddPharmacy(pharmacy);
|
---|
124 | throw new Exception("Pharmacy is null");
|
---|
125 | }
|
---|
126 |
|
---|
127 | public Task AddPharmacyHead(PharmacyHead pharmacyHead)
|
---|
128 | {
|
---|
129 | if (pharmacyHead != null)
|
---|
130 | _repository.AddPharmacyHead(pharmacyHead);
|
---|
131 | throw new Exception("PharmacyHead is null");
|
---|
132 | }
|
---|
133 |
|
---|
134 | public Task AddWorker(HealthcareWorkers worker)
|
---|
135 | {
|
---|
136 | if (worker != null)
|
---|
137 | _repository.AddWorker(worker);
|
---|
138 | throw new Exception("Worker is null");
|
---|
139 | }
|
---|
140 |
|
---|
141 | //PUT (EDIT OBJECTS)
|
---|
142 |
|
---|
143 |
|
---|
144 | //DELETE
|
---|
145 |
|
---|
146 | }
|
---|
147 | }
|
---|