source: FarmatikoServices/Services/MedicineService.cs@ d8fafb8

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

Update & add service

  • Property mode set to 100644
File size: 2.1 KB
RevLine 
[e42f61a]1using FarmatikoData.FarmatikoRepoInterfaces;
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 MedicineService : IMedicineService
11 {
12 private IMedicineRepository _medicineRepository;
13 public MedicineService(IMedicineRepository medicineRepository)
14 {
15 _medicineRepository = medicineRepository;
16 }
17
18 public void Add(Medicine medicine)
19 {
[a55ef91]20 try
21 {
22 if (medicine != null)
23 _medicineRepository.Add(medicine);
24 }
25 catch (Exception e)
26 {
27 e = new Exception("Can't Add medicine is null");
28 throw e;
29 }
[e42f61a]30 }
31
[a55ef91]32 public IQueryable<Medicine> GetAll()
[e42f61a]33 {
34 return _medicineRepository.GetAll();
35 }
36
[a55ef91]37 public IQueryable<Medicine> GetByManufacturer(string Manufacturer)
[e42f61a]38 {
[a55ef91]39 try
40 {
41 if (Manufacturer != null)
42 return _medicineRepository.GetByManufacturer(Manufacturer);
43 }
44 catch (Exception e)
45 {
46 e = new Exception("Can't get, name of manufacturer is null");
47 throw e;
48 }
49
50 return null;
[e42f61a]51 }
52
[a55ef91]53 public IQueryable<Medicine> GetByName(string Name)
[e42f61a]54 {
[a55ef91]55 try
56 {
57 if (Name != null)
58 return _medicineRepository.GetByName(Name);
59 }
60 catch (Exception e)
61 {
62 e = new Exception("Can't get, name is null");
63 }
64
65 return null;
[e42f61a]66 }
67
68 public void Remove(string Medicine)
69 {
[a55ef91]70 try
71 {
72 if (Medicine != null)
73 _medicineRepository.Remove(Medicine);
74 }
75 catch (Exception e)
76 {
77 e = new Exception("Can't Add medicine is null");
78 throw e;
79 }
[e42f61a]80 }
81 }
82}
Note: See TracBrowser for help on using the repository browser.