[e42f61a] | 1 | using FarmatikoData.FarmatikoRepo;
|
---|
| 2 | using FarmatikoData.Models;
|
---|
| 3 | using FarmatikoServices.FarmatikoServiceInterfaces;
|
---|
[a55ef91] | 4 | using System;
|
---|
[e42f61a] | 5 | using System.Collections.Generic;
|
---|
[a55ef91] | 6 | using System.Linq;
|
---|
[c406ae5] | 7 | using System.Threading.Tasks;
|
---|
[e42f61a] | 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 |
|
---|
[c406ae5] | 19 | public async void Add(MedicineList medicineList)
|
---|
[a55ef91] | 20 | {
|
---|
[c406ae5] | 21 | if (medicineList != null)
|
---|
| 22 | await Task.Run(() => _medicineListRepository.Add(medicineList));
|
---|
| 23 | else throw new Exception("Can't add, the medicine list is null.");
|
---|
[a55ef91] | 24 | }
|
---|
| 25 |
|
---|
[c406ae5] | 26 | public async Task<IQueryable<MedicineList>> GetAll()
|
---|
[e42f61a] | 27 | {
|
---|
[c406ae5] | 28 | return await Task.Run(() => _medicineListRepository.GetAll());
|
---|
[e42f61a] | 29 | }
|
---|
| 30 |
|
---|
[c406ae5] | 31 | public async Task<ICollection<MedicineList>> GetByManufacturer(string Manufacturer)
|
---|
[e42f61a] | 32 | {
|
---|
[c406ae5] | 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");
|
---|
[e42f61a] | 36 | }
|
---|
| 37 |
|
---|
[c406ae5] | 38 | public async Task<ICollection<MedicineList>> GetByName(string Name)
|
---|
[e42f61a] | 39 | {
|
---|
[c406ae5] | 40 | if (Name != null)
|
---|
| 41 | return await Task.Run(() => _medicineListRepository.GetByName(Name));
|
---|
| 42 | else throw new Exception("Can't get, name is null");
|
---|
[e42f61a] | 43 | }
|
---|
| 44 |
|
---|
[c406ae5] | 45 | public async void Remove(MedicineList medicineList)
|
---|
[e42f61a] | 46 | {
|
---|
[c406ae5] | 47 | if (medicineList != null)
|
---|
| 48 | await Task.Run(() => _medicineListRepository.Remove(medicineList));
|
---|
| 49 | else throw new Exception("Can't remove, the medicine list is null.");
|
---|
[e42f61a] | 50 | }
|
---|
| 51 | }
|
---|
| 52 | }
|
---|