source: FarmatikoServices/Services/PharmacyService.cs@ 5d02859

Last change on this file since 5d02859 was c406ae5, checked in by DimitarSlezenkovski <dslezenkovski@…>, 4 years ago

Update Models, Repos, Services and Controllers

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