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 | using System.Threading.Tasks;
|
---|
8 |
|
---|
9 | namespace FarmatikoServices.Services
|
---|
10 | {
|
---|
11 | public class PharmacyService : IPharmacyService
|
---|
12 | {
|
---|
13 | private IPharmacyRepository _pharmacyRepository;
|
---|
14 | public PharmacyService(IPharmacyRepository pharmacyRepository)
|
---|
15 | {
|
---|
16 | _pharmacyRepository = pharmacyRepository;
|
---|
17 | }
|
---|
18 | public async void Add(Pharmacy pharmacy)
|
---|
19 | {
|
---|
20 | if (pharmacy != null)
|
---|
21 | await Task.Run(() => _pharmacyRepository.Add(pharmacy));
|
---|
22 | else throw new Exception("Can't add, pharmacy has null value.");
|
---|
23 | }
|
---|
24 |
|
---|
25 | public async Task<IQueryable<Pharmacy>> GetAll()
|
---|
26 | {
|
---|
27 | return await Task.Run(() => _pharmacyRepository.GetAll());
|
---|
28 | }
|
---|
29 |
|
---|
30 | public async Task<ICollection<Pharmacy>> GetPharmacies()
|
---|
31 | {
|
---|
32 | return await Task.Run(() => _pharmacyRepository.GetPharmacies());
|
---|
33 | }
|
---|
34 |
|
---|
35 | public async void Remove(Pharmacy pharmacy)
|
---|
36 | {
|
---|
37 | if (pharmacy != null)
|
---|
38 | await Task.Run(() => _pharmacyRepository.Remove(pharmacy));
|
---|
39 | else throw new Exception("Can't remove, pharmacy has null value.");
|
---|
40 | }
|
---|
41 |
|
---|
42 | public async void UpdatePharmacy(Pharmacy pharmacy)
|
---|
43 | {
|
---|
44 | if (pharmacy != null)
|
---|
45 | await Task.Run(() => _pharmacyRepository.UpdatePharmacy(pharmacy));
|
---|
46 | else throw new Exception("Can not update pharmacy, has null value.");
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|