source: FarmatikoServices/Services/PharmacyHeadService.cs@ 58fa654

Last change on this file since 58fa654 was a55ef91, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago

Update & add service

  • Property mode set to 100644
File size: 2.4 KB
Line 
1using FarmatikoData.FarmatikoRepoInterfaces;
2using FarmatikoData.Models;
3using FarmatikoServices.FarmatikoServiceInterfaces;
4using System;
5using System.Linq;
6
7namespace 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}
Note: See TracBrowser for help on using the repository browser.