source: FarmatikoServices/Services/PharmacyHeadService.cs@ c406ae5

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

Update Models, Repos, Services and Controllers

  • Property mode set to 100644
File size: 2.3 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 PharmacyHeadService : IPharmacyHeadService
11 {
12 private IPharmacyHeadRepository _pharmacyHeadRepository;
13 public PharmacyHeadService(IPharmacyHeadRepository pharmacyHeadRepository)
14 {
15 _pharmacyHeadRepository = pharmacyHeadRepository;
16 }
17
18 public async void Add(PharmacyHead pharmacyHead)
19 {
20 if (pharmacyHead != null)
21 await Task.Run(() => _pharmacyHeadRepository.Add(pharmacyHead));
22 else throw new Exception("Can't add, pharmacy head is null.");
23 }
24
25 public async Task<IQueryable<PharmacyHead>> GetAllPharmacies(string NameOfPharmacyHead)
26 {
27 if (NameOfPharmacyHead != null)
28 {
29 IQueryable<PharmacyHead> pharmacies = await Task.Run(() => _pharmacyHeadRepository.GetAllPharmacies(NameOfPharmacyHead));
30 if (pharmacies != null)
31 return pharmacies;
32 }
33 return null;
34 }
35
36 public async Task<IQueryable<PharmacyHead>> GetPharmacyByName(string Name)
37 {
38 if (Name != null)
39 {
40 IQueryable<PharmacyHead> PharmacyHead = await Task.Run(() => _pharmacyHeadRepository.GetPharmacyByName(Name));
41 if (PharmacyHead != null)
42 return PharmacyHead;
43 }
44 return null;
45 }
46
47 public async Task<IQueryable<MedicineList>> GetPharmacyMedicines(string NameOfPharmacy)
48 {
49 if (NameOfPharmacy != null)
50 {
51 IQueryable<MedicineList> Medicines = await Task.Run(() => _pharmacyHeadRepository.GetPharmacyMedicines(NameOfPharmacy));
52 if (Medicines != null)
53 return Medicines;
54 }
55 return null;
56 }
57
58 public async void Remove(PharmacyHead pharmacyHead)
59 {
60 if (pharmacyHead != null)
61 await Task.Run(() => _pharmacyHeadRepository.Remove(pharmacyHead));
62 else throw new Exception("Can't remove, name of pharmacy head is null.");
63 }
64 }
65}
Note: See TracBrowser for help on using the repository browser.