1 | using FarmatikoData.FarmatikoRepoInterfaces;
|
---|
2 | using FarmatikoData.Models;
|
---|
3 | using FarmatikoServices.FarmatikoServiceInterfaces;
|
---|
4 | using System;
|
---|
5 | using System.Collections.Generic;
|
---|
6 | using System.Linq;
|
---|
7 |
|
---|
8 | namespace FarmatikoServices.Services
|
---|
9 | {
|
---|
10 | public class PharmacyService : IPharmacyService
|
---|
11 | {
|
---|
12 | private IPharmacyRepository _pharmacyRepository;
|
---|
13 | public PharmacyService(IPharmacyRepository pharmacyRepository)
|
---|
14 | {
|
---|
15 | _pharmacyRepository = pharmacyRepository;
|
---|
16 | }
|
---|
17 | public void Add(Pharmacy pharmacy)
|
---|
18 | {
|
---|
19 | try
|
---|
20 | {
|
---|
21 | if (pharmacy != null)
|
---|
22 | {
|
---|
23 | _pharmacyRepository.Add(pharmacy);
|
---|
24 | }
|
---|
25 | }
|
---|
26 | catch (Exception e)
|
---|
27 | {
|
---|
28 | e = new Exception("Can't add, pharmacy has null value.");
|
---|
29 | throw e;
|
---|
30 | }
|
---|
31 |
|
---|
32 | }
|
---|
33 |
|
---|
34 | public IQueryable<Pharmacy> GetAll()
|
---|
35 | {
|
---|
36 | return _pharmacyRepository.GetAll();
|
---|
37 | }
|
---|
38 |
|
---|
39 | public ICollection<Pharmacy> GetPharmacies()
|
---|
40 | {
|
---|
41 | return _pharmacyRepository.GetPharmacies();
|
---|
42 | }
|
---|
43 |
|
---|
44 | public void Remove(Pharmacy pharmacy)
|
---|
45 | {
|
---|
46 | try
|
---|
47 | {
|
---|
48 | if (pharmacy != null)
|
---|
49 | _pharmacyRepository.Remove(pharmacy);
|
---|
50 | }
|
---|
51 | catch (Exception e)
|
---|
52 | {
|
---|
53 | e = new Exception("Can't remove, pharmacy has null value.");
|
---|
54 | throw e;
|
---|
55 | }
|
---|
56 | }
|
---|
57 |
|
---|
58 | public void UpdatePharmacy(Pharmacy pharmacy, string Name)
|
---|
59 | {
|
---|
60 | try
|
---|
61 | {
|
---|
62 | if (pharmacy != null && Name != null)
|
---|
63 | {
|
---|
64 | _pharmacyRepository.UpdatePharmacy(pharmacy, Name);
|
---|
65 | }
|
---|
66 | }
|
---|
67 | catch (Exception e)
|
---|
68 | {
|
---|
69 | e = new Exception("Can not update pharmacy, has null value.");
|
---|
70 | throw e;
|
---|
71 | }
|
---|
72 |
|
---|
73 | }
|
---|
74 | }
|
---|
75 | }
|
---|