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
RevLine 
[4e72684]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 {
[a55ef91]19 try
[4e72684]20 {
[a55ef91]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.");
[4e72684]29 }
[a55ef91]30
[4e72684]31 }
32
33 public IQueryable<PharmacyHead> GetAllPharmacies(string NameOfPharmacyHead)
34 {
[a55ef91]35 if (NameOfPharmacyHead != null)
[4e72684]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 {
[a55ef91]46 if (Name != null)
[4e72684]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 {
[a55ef91]57 if (NameOfPharmacy != null)
[4e72684]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 {
[a55ef91]68 try
69 {
70 if (Name != null)
71 {
72 _pharmacyHeadRepository.Remove(pharmacyHead, Name);
73 }
74 }
75 catch (Exception e)
[4e72684]76 {
[a55ef91]77 e = new Exception("Can't remove, name of pharmacy head is null.");
[4e72684]78 }
[a55ef91]79
[4e72684]80 }
81 }
82}
Note: See TracBrowser for help on using the repository browser.