1 | using FarmatikoData.FarmatikoRepo;
|
---|
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 MedicineListService : IMedicineListService
|
---|
12 | {
|
---|
13 | private IMedicineListRepository _medicineListRepository;
|
---|
14 | public MedicineListService(IMedicineListRepository medicineListRepository)
|
---|
15 | {
|
---|
16 | _medicineListRepository = medicineListRepository;
|
---|
17 | }
|
---|
18 |
|
---|
19 | public async void Add(MedicineList medicineList)
|
---|
20 | {
|
---|
21 | if (medicineList != null)
|
---|
22 | await Task.Run(() => _medicineListRepository.Add(medicineList));
|
---|
23 | else throw new Exception("Can't add, the medicine list is null.");
|
---|
24 | }
|
---|
25 |
|
---|
26 | public async Task<IQueryable<MedicineList>> GetAll()
|
---|
27 | {
|
---|
28 | return await Task.Run(() => _medicineListRepository.GetAll());
|
---|
29 | }
|
---|
30 |
|
---|
31 | public async Task<ICollection<MedicineList>> GetByManufacturer(string Manufacturer)
|
---|
32 | {
|
---|
33 | if (Manufacturer != null)
|
---|
34 | return await Task.Run(() => _medicineListRepository.GetByManufacturer(Manufacturer));
|
---|
35 | else throw new Exception("Can't get, name of manufacturer is null");
|
---|
36 | }
|
---|
37 |
|
---|
38 | public async Task<ICollection<MedicineList>> GetByName(string Name)
|
---|
39 | {
|
---|
40 | if (Name != null)
|
---|
41 | return await Task.Run(() => _medicineListRepository.GetByName(Name));
|
---|
42 | else throw new Exception("Can't get, name is null");
|
---|
43 | }
|
---|
44 |
|
---|
45 | public async void Remove(MedicineList medicineList)
|
---|
46 | {
|
---|
47 | if (medicineList != null)
|
---|
48 | await Task.Run(() => _medicineListRepository.Remove(medicineList));
|
---|
49 | else throw new Exception("Can't remove, the medicine list is null.");
|
---|
50 | }
|
---|
51 | }
|
---|
52 | }
|
---|