- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoServices/Services/MedicineService.cs
rc406ae5 ra55ef91 5 5 using System.Collections.Generic; 6 6 using System.Linq; 7 using System.Threading.Tasks;8 7 9 8 namespace FarmatikoServices.Services … … 17 16 } 18 17 19 public asyncvoid Add(Medicine medicine)18 public void Add(Medicine medicine) 20 19 { 21 if (medicine != null) 22 await Task.Run(() => _medicineRepository.Add(medicine)); 23 else throw new Exception("Can't Add medicine is null"); 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 } 24 30 } 25 31 26 public async Task<IQueryable<Medicine>> GetAll()32 public IQueryable<Medicine> GetAll() 27 33 { 28 return await Task.Run(() => _medicineRepository.GetAll());34 return _medicineRepository.GetAll(); 29 35 } 30 36 31 public async Task<IQueryable<Medicine>> GetByManufacturer(string Manufacturer)37 public IQueryable<Medicine> GetByManufacturer(string Manufacturer) 32 38 { 33 if (Manufacturer != null) 34 return await Task.Run(() => _medicineRepository.GetByManufacturer(Manufacturer)); 35 else throw new Exception("Can't get, name of manufacturer is null"); 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; 36 51 } 37 52 38 public async Task<IQueryable<Medicine>> GetByName(string Name)53 public IQueryable<Medicine> GetByName(string Name) 39 54 { 40 if (Name != null) 41 return await Task.Run(() => _medicineRepository.GetByName(Name)); 42 else throw new Exception("Can't get, name is null"); 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; 43 66 } 44 67 45 public async void Remove(MedicineMedicine)68 public void Remove(string Medicine) 46 69 { 47 if (Medicine != null) 48 await Task.Run(() => _medicineRepository.Remove(Medicine)); 49 else throw new Exception("Can't Add medicine is null"); 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 } 50 80 } 51 81 }
Note:
See TracChangeset
for help on using the changeset viewer.