Changeset 1454207 for FarmatikoServices/Services/Service.cs
- Timestamp:
- 10/01/20 03:17:09 (4 years ago)
- Branches:
- master
- Children:
- 6f203af
- Parents:
- 5d02859
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoServices/Services/Service.cs
r5d02859 r1454207 17 17 18 18 //GET 19 public async Task<IQueryable<HealthcareWorker s>> GetAllWorkers()19 public async Task<IQueryable<HealthcareWorker>> GetAllWorkers() 20 20 { 21 21 var Workers = await _repository.GetAllWorkers(); … … 23 23 } 24 24 25 public async Task<IQueryable<HealthFacilit ies>> GetFacilities()25 public async Task<IQueryable<HealthFacility>> GetFacilities() 26 26 { 27 27 var Facilities = await _repository.GetFacilities(); … … 29 29 } 30 30 31 public async Task<HealthFacilit ies> GetFacility(int id)31 public async Task<HealthFacility> GetFacility(int id) 32 32 { 33 33 var Facility = await _repository.GetFacility(id); … … 65 65 } 66 66 67 public async Task<HealthcareWorker s> GetWorker(int id)67 public async Task<HealthcareWorker> GetWorker(int id) 68 68 { 69 69 var Worker = await _repository.GetWorker(id); … … 71 71 } 72 72 73 public async Task<IQueryable<HealthFacilit ies>> SearchFacilities(string query)73 public async Task<IQueryable<HealthFacility>> SearchFacilities(string query) 74 74 { 75 75 var SearchQuery = await _repository.SearchFacilities(query); … … 89 89 } 90 90 91 public async Task<IQueryable<HealthcareWorker s>> SearchWorkers(string query)91 public async Task<IQueryable<HealthcareWorker>> SearchWorkers(string query) 92 92 { 93 93 var SearchQuery = await _repository.SearchWorkers(query); … … 97 97 98 98 //POST (ADD NEW OBJECTS) 99 public Task AddFacility(HealthFacilities healthFacilities) 99 //za json(Sys updateer) 100 public async Task AddFacility(HealthFacility healthFacilities) 100 101 { 101 102 if (healthFacilities != null) 102 _repository.AddFacility(healthFacilities);103 await _repository.AddFacility(healthFacilities); 103 104 throw new Exception("Facility is null"); 104 105 } 105 106 public Task AddMedicines(Medicine medicine)106 //za json(Sys updateer) 107 public async Task AddMedicines(Medicine medicine) 107 108 { 108 109 if (medicine != null) 109 _repository.AddMedicines(medicine);110 await _repository.AddMedicines(medicine); 110 111 throw new Exception("Medicine is null"); 111 112 } 112 113 public Task AddPandemic(Pandemic pandemic)113 //za json(Sys updateer) 114 public async Task AddPandemic(Pandemic pandemic) 114 115 { 115 116 if (pandemic != null) 116 _repository.AddPandemic(pandemic);117 await _repository.AddPandemic(pandemic); 117 118 throw new Exception("Pandemic is null"); 118 119 } 119 120 public Task AddPharmacy(Pharmacy pharmacy)120 // Samo PharmacyHead i Admin imaat pristap 121 public async Task AddPharmacy(Pharmacy pharmacy) 121 122 { 122 123 if (pharmacy != null) 123 _repository.AddPharmacy(pharmacy);124 await _repository.AddPharmacy(pharmacy); 124 125 throw new Exception("Pharmacy is null"); 125 126 } 126 127 public Task AddPharmacyHead(PharmacyHead pharmacyHead)127 // Ovaa kontrola ja ima samo admin 128 public async Task AddPharmacyHead(PharmacyHead pharmacyHead) 128 129 { 129 130 if (pharmacyHead != null) 130 _repository.AddPharmacyHead(pharmacyHead); 131 { 132 var Medicines = await _repository.GetMedicines(); 133 foreach (var med in Medicines) 134 { 135 MedicineList medicine = new MedicineList() 136 { 137 Medicine = med, 138 HasMedicine = false 139 }; 140 pharmacyHead.MedicineLists.Add(medicine); 141 } 142 await _repository.AddPharmacyHead(pharmacyHead); 143 } 131 144 throw new Exception("PharmacyHead is null"); 132 145 } 133 134 public Task AddWorker(HealthcareWorkersworker)146 //za json(Sys updateer) 147 public async Task AddWorker(HealthcareWorker worker) 135 148 { 136 149 if (worker != null) 137 _repository.AddWorker(worker);150 await _repository.AddWorker(worker); 138 151 throw new Exception("Worker is null"); 152 } 153 154 //za json(Sys updateer) 155 public async Task UpdateFacility(HealthFacility healthFacilities) 156 { 157 if (healthFacilities != null) 158 await _repository.UpdateFacility(healthFacilities); 159 throw new Exception("Facility is null"); 160 } 161 //PharmacyHead 162 public async Task RemoveMedicine(Medicine medicine) 163 { 164 if (medicine != null) 165 await _repository.RemoveMedicine(medicine); 166 throw new Exception("Medicine is null"); 167 } 168 //PharmacyHead 169 public async Task UpdateMedicine(Medicine medicine) 170 { 171 if (medicine != null) 172 await _repository.UpdateMedicine(medicine); 173 throw new Exception("Medicine is null"); 174 } 175 //za json(Sys updateer) 176 public async Task UpdatePandemic(Pandemic pandemic) 177 { 178 if (pandemic != null) 179 await _repository.UpdatePandemic(pandemic); 180 throw new Exception("Pandemic is null"); 181 } 182 //PharmacyHead 183 public async Task RemovePharmacy(Pharmacy pharmacy) 184 { 185 if (pharmacy != null) 186 await _repository.RemovePharmacy(pharmacy); 187 throw new Exception("Pharmacy is null"); 188 } 189 //PharamcyHead 190 public async Task UpdatePharmacy(Pharmacy pharmacy) 191 { 192 if (pharmacy != null) 193 await _repository.UpadatePharmacy(pharmacy); 194 throw new Exception("Pharmacy is null"); 195 } 196 //za json(Sys updateer) 197 public async Task UpdateWorker(HealthcareWorker worker) 198 { 199 if (worker != null) 200 await _repository.UpdateWorker(worker); 201 throw new Exception("Worker is null"); 202 } 203 204 public async Task RemovePharmacyHead(PharmacyHead pharmacyHead) 205 { 206 if (pharmacyHead != null) 207 { 208 pharmacyHead.DeletedOn = DateTime.UtcNow; 209 await _repository.RemovePharmacyHead(pharmacyHead); 210 } 211 else throw new Exception("PharmacyHead is null."); 212 } 213 214 public async Task<HealthFacility> GetFacilityJSON(string healthFacility) 215 { 216 if (healthFacility != null) 217 return await _repository.GetFacilityJSON(healthFacility); 218 return null; 139 219 } 140 220
Note:
See TracChangeset
for help on using the changeset viewer.