Changeset f554983 for FarmatikoServices/Services/Service.cs
- Timestamp:
- 02/14/21 17:54:35 (4 years ago)
- Branches:
- master
- Children:
- 472dd7e
- Parents:
- 6e6f04b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoServices/Services/Service.cs
r6e6f04b rf554983 144 144 var Pharmacies = await _repository.GetPharmacies(); 145 145 List<PharmacyDTO> pharmacies = new List<PharmacyDTO>(); 146 147 foreach (var pharm in Pharmacies)146 147 foreach (var pharm in Pharmacies) 148 148 { 149 149 PharmacyDTO pharmacyDTO = new PharmacyDTO() … … 222 222 List<PharmacyDTO> pharmacies = new List<PharmacyDTO>(); 223 223 var heads = await _phrepo.GetPharmacyHeadInfo(); 224 224 225 225 foreach (var pharm in SearchQuery) 226 226 { … … 232 232 WorkAllTime = pharm.WorkAllTime 233 233 }; 234 235 foreach (var head in heads.ToList())234 235 foreach (var head in heads.ToList()) 236 236 { 237 237 if (head.Pharmacies.Contains(pharm)) … … 241 241 } 242 242 } 243 243 244 244 pharmacies.Add(pharmacyDTO); 245 245 } … … 256 256 //POST (ADD NEW OBJECTS) 257 257 //za json(Sys updateer) 258 public async Task AddFacility(HealthFacility healthFacilities) 259 { 260 if (healthFacilities != null) 261 await _repository.AddFacility(healthFacilities); 258 public async Task AddFacility(HealthFacility healthFacility) 259 { 260 if (healthFacility != null) 261 { 262 var facilities = await _repository.GetFacilities(); 263 if (!facilities.Contains(healthFacility)) 264 { 265 await _repository.AddFacility(healthFacility); 266 } 267 else throw new Exception("The facility already exists."); 268 } 262 269 else throw new Exception("Facility is null"); 263 270 } … … 266 273 { 267 274 if (medicine != null) 268 await _repository.AddMedicines(medicine); 275 { 276 var medicines = await _repository.GetMedicinesAsync(); 277 if (!medicines.Contains(medicine)) 278 await _repository.AddMedicines(medicine); 279 else throw new Exception("Medicine already exists."); 280 } 269 281 else throw new Exception("Medicine is null"); 270 282 } … … 277 289 } 278 290 // Samo PharmacyHead i Admin imaat pristap 279 public void AddPharmacy(Pharmacy pharmacy)291 public async void AddPharmacy(Pharmacy pharmacy) 280 292 { 281 293 if (pharmacy != null) 282 _repository.AddPharmacy(pharmacy); 294 { 295 var pharmacies = await _repository.GetPharmacies(); 296 if (!pharmacies.Contains(pharmacy)) 297 await _repository.AddPharmacy(pharmacy); 298 else throw new Exception("Pharmacy already exists."); 299 } 283 300 else throw new Exception("Pharmacy is null"); 284 301 } 285 302 286 303 // Ovaa kontrola ja ima samo admin 287 304 288 305 public async Task<bool> AddPharmacyHead(PharmacyHeadDto pharmacyHead) 289 306 { … … 324 341 { 325 342 if (worker != null) 326 await _repository.AddWorker(worker); 343 { 344 var workers = await _repository.GetAllWorkers(); 345 if (!workers.Contains(worker)) 346 await _repository.AddWorker(worker); 347 else throw new Exception("Worker already exists."); 348 } 327 349 else throw new Exception("Worker is null"); 328 350 }
Note:
See TracChangeset
for help on using the changeset viewer.