source: FarmatikoServices/Services/MedicineListService.cs@ c73269d

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

Update & add service

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[e42f61a]1using FarmatikoData.FarmatikoRepo;
2using FarmatikoData.Models;
3using FarmatikoServices.FarmatikoServiceInterfaces;
[a55ef91]4using System;
[e42f61a]5using System.Collections.Generic;
[a55ef91]6using System.Linq;
[e42f61a]7
8namespace FarmatikoServices.Services
9{
10 public class MedicineListService : IMedicineListService
11 {
12 private IMedicineListRepository _medicineListRepository;
13 public MedicineListService(IMedicineListRepository medicineListRepository)
14 {
15 _medicineListRepository = medicineListRepository;
16 }
17
[a55ef91]18 public void Add(MedicineList medicineList)
19 {
20 try
21 {
22 if (medicineList != null)
23 _medicineListRepository.Add(medicineList);
24 }
25 catch (Exception e)
26 {
27 e = new Exception("Can't add the medicine list is null.");
28 throw e;
29 }
30 }
31
32 public IQueryable<MedicineList> GetAll()
[e42f61a]33 {
34 return _medicineListRepository.GetAll();
35 }
36
37 public ICollection<MedicineList> GetByManufacturer(string Manufacturer)
38 {
[a55ef91]39 try
40 {
41 if (Manufacturer != null)
42 {
43
44 return _medicineListRepository.GetByManufacturer(Manufacturer);
45 }
46 }
47 catch (Exception e)
48 {
49 e = new Exception("Can't get name of manufacturer is null");
50 throw e;
51 }
52 return null;
[e42f61a]53 }
54
55 public ICollection<MedicineList> GetByName(string Name)
56 {
[a55ef91]57 try
[4e72684]58 {
[a55ef91]59 if (Name != null)
60 {
61 return _medicineListRepository.GetByName(Name);
62 }
63 }
64 catch (Exception e)
65 {
66 e = new Exception("Can't get name is null");
67 throw e;
[4e72684]68 }
69 return null;
[e42f61a]70 }
71
[a55ef91]72 public void Remove(MedicineList medicineList)
[e42f61a]73 {
[a55ef91]74 try
75 {
76 if (medicineList != null)
77 _medicineListRepository.Remove(medicineList);
78 }
79 catch (Exception e)
[4e72684]80 {
[a55ef91]81 e = new Exception("Can't remove the medicine list is null.");
82 throw e;
[4e72684]83 }
[e42f61a]84 }
85 }
86}
Note: See TracBrowser for help on using the repository browser.