1 | using FarmatikoData.FarmatikoRepoInterfaces;
|
---|
2 | using FarmatikoData.Models;
|
---|
3 | using FarmatikoServices.FarmatikoServiceInterfaces;
|
---|
4 | using System;
|
---|
5 | using System.Linq;
|
---|
6 |
|
---|
7 | namespace FarmatikoServices.Services
|
---|
8 | {
|
---|
9 | public class PharmacyHeadService : IPharmacyHeadService
|
---|
10 | {
|
---|
11 | private IPharmacyHeadRepository _pharmacyHeadRepository;
|
---|
12 | public PharmacyHeadService(IPharmacyHeadRepository pharmacyHeadRepository)
|
---|
13 | {
|
---|
14 | _pharmacyHeadRepository = pharmacyHeadRepository;
|
---|
15 | }
|
---|
16 |
|
---|
17 | public void Add(PharmacyHead pharmacyHead)
|
---|
18 | {
|
---|
19 | try
|
---|
20 | {
|
---|
21 | if (pharmacyHead != null)
|
---|
22 | {
|
---|
23 | _pharmacyHeadRepository.Add(pharmacyHead);
|
---|
24 | }
|
---|
25 | }
|
---|
26 | catch (Exception e)
|
---|
27 | {
|
---|
28 | e = new Exception("Can't add, pharmacy head is null.");
|
---|
29 | }
|
---|
30 |
|
---|
31 | }
|
---|
32 |
|
---|
33 | public IQueryable<PharmacyHead> GetAllPharmacies(string NameOfPharmacyHead)
|
---|
34 | {
|
---|
35 | if (NameOfPharmacyHead != null)
|
---|
36 | {
|
---|
37 | IQueryable<PharmacyHead> Pharmacy = _pharmacyHeadRepository.GetAllPharmacies(NameOfPharmacyHead);
|
---|
38 | if (Pharmacy != null)
|
---|
39 | return Pharmacy;
|
---|
40 | }
|
---|
41 | return null;
|
---|
42 | }
|
---|
43 |
|
---|
44 | public IQueryable<PharmacyHead> GetPharmacyByName(string Name)
|
---|
45 | {
|
---|
46 | if (Name != null)
|
---|
47 | {
|
---|
48 | IQueryable<PharmacyHead> PharmacyHead = _pharmacyHeadRepository.GetPharmacyByName(Name);
|
---|
49 | if (PharmacyHead != null)
|
---|
50 | return PharmacyHead;
|
---|
51 | }
|
---|
52 | return null;
|
---|
53 | }
|
---|
54 |
|
---|
55 | public IQueryable<MedicineList> GetPharmacyMedicines(string NameOfPharmacy)
|
---|
56 | {
|
---|
57 | if (NameOfPharmacy != null)
|
---|
58 | {
|
---|
59 | IQueryable<MedicineList> Medicines = _pharmacyHeadRepository.GetPharmacyMedicines(NameOfPharmacy);
|
---|
60 | if (Medicines != null)
|
---|
61 | return Medicines;
|
---|
62 | }
|
---|
63 | return null;
|
---|
64 | }
|
---|
65 |
|
---|
66 | public void Remove(PharmacyHead pharmacyHead, string Name)
|
---|
67 | {
|
---|
68 | try
|
---|
69 | {
|
---|
70 | if (Name != null)
|
---|
71 | {
|
---|
72 | _pharmacyHeadRepository.Remove(pharmacyHead, Name);
|
---|
73 | }
|
---|
74 | }
|
---|
75 | catch (Exception e)
|
---|
76 | {
|
---|
77 | e = new Exception("Can't remove, name of pharmacy head is null.");
|
---|
78 | }
|
---|
79 |
|
---|
80 | }
|
---|
81 | }
|
---|
82 | }
|
---|