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
RevLine 
[4e72684]1using FarmatikoData.FarmatikoRepoInterfaces;
2using FarmatikoData.Models;
3using FarmatikoServices.FarmatikoServiceInterfaces;
[a55ef91]4using System;
[4e72684]5using System.Collections.Generic;
[a55ef91]6using System.Linq;
[c406ae5]7using System.Threading.Tasks;
[4e72684]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 }
[c406ae5]18 public async void Add(Pharmacy pharmacy)
[4e72684]19 {
[c406ae5]20 if (pharmacy != null)
21 await Task.Run(() => _pharmacyRepository.Add(pharmacy));
22 else throw new Exception("Can't add, pharmacy has null value.");
[4e72684]23 }
24
[c406ae5]25 public async Task<IQueryable<Pharmacy>> GetAll()
[4e72684]26 {
[c406ae5]27 return await Task.Run(() => _pharmacyRepository.GetAll());
[4e72684]28 }
29
[c406ae5]30 public async Task<ICollection<Pharmacy>> GetPharmacies()
[4e72684]31 {
[c406ae5]32 return await Task.Run(() => _pharmacyRepository.GetPharmacies());
[4e72684]33 }
34
[c406ae5]35 public async void Remove(Pharmacy pharmacy)
[4e72684]36 {
[c406ae5]37 if (pharmacy != null)
38 await Task.Run(() => _pharmacyRepository.Remove(pharmacy));
39 else throw new Exception("Can't remove, pharmacy has null value.");
[4e72684]40 }
41
[c406ae5]42 public async void UpdatePharmacy(Pharmacy pharmacy)
[4e72684]43 {
[c406ae5]44 if (pharmacy != null)
45 await Task.Run(() => _pharmacyRepository.UpdatePharmacy(pharmacy));
46 else throw new Exception("Can not update pharmacy, has null value.");
[4e72684]47 }
48 }
49}
Note: See TracBrowser for help on using the repository browser.