- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FarmatikoServices/Services/PandemicService.cs
ra55ef91 rc406ae5 4 4 using System; 5 5 using System.Linq; 6 using System.Threading.Tasks; 6 7 7 8 namespace FarmatikoServices.Services … … 15 16 } 16 17 17 public void Add(Pandemic pandemic)18 public async void Add(Pandemic pandemic) 18 19 { 19 try 20 { 21 if (pandemic != null) 22 { 23 _pandemicRepository.Add(pandemic); 24 } 25 } 26 catch (Exception e) 27 { 28 e = new Exception("Can't add pandemic is null."); 29 throw e; 30 } 20 if (pandemic != null) 21 await Task.Run(() => _pandemicRepository.Add(pandemic)); 22 else throw new Exception("Can't add pandemic is null."); 31 23 } 32 24 33 public IQueryable<Pandemic> GetAll()25 public async Task<IQueryable<Pandemic>> GetAll() 34 26 { 35 return _pandemicRepository.GetAll();27 return await Task.Run(() => _pandemicRepository.GetAll()); 36 28 } 37 29 38 public void Remove(Pandemic pandemic)30 public async void Remove(Pandemic pandemic) 39 31 { 40 try 41 { 42 if (pandemic != null) 43 _pandemicRepository.Remove(pandemic); 44 } 45 catch (Exception e) 46 { 47 e = new Exception("Can't remove, pandemic is null."); 48 } 32 if (pandemic != null) 33 await Task.Run(() => _pandemicRepository.Remove(pandemic)); 34 else throw new Exception("Can't remove, pandemic is null."); 49 35 } 50 36 }
Note:
See TracChangeset
for help on using the changeset viewer.