source: FarmatikoServices/Services/PandemicService.cs@ 63d885e

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

Update Models, Repos, Services and Controllers

  • Property mode set to 100644
File size: 1.1 KB
Line 
1using FarmatikoData.FarmatikoRepoInterfaces;
2using FarmatikoData.Models;
3using FarmatikoServices.FarmatikoServiceInterfaces;
4using System;
5using System.Linq;
6using System.Threading.Tasks;
7
8namespace FarmatikoServices.Services
9{
10 public class PandemicService : IPandemicService
11 {
12 private IPandemicRepository _pandemicRepository;
13 public PandemicService(IPandemicRepository pandemicRepository)
14 {
15 _pandemicRepository = pandemicRepository;
16 }
17
18 public async void Add(Pandemic pandemic)
19 {
20 if (pandemic != null)
21 await Task.Run(() => _pandemicRepository.Add(pandemic));
22 else throw new Exception("Can't add pandemic is null.");
23 }
24
25 public async Task<IQueryable<Pandemic>> GetAll()
26 {
27 return await Task.Run(() => _pandemicRepository.GetAll());
28 }
29
30 public async void Remove(Pandemic pandemic)
31 {
32 if (pandemic != null)
33 await Task.Run(() => _pandemicRepository.Remove(pandemic));
34 else throw new Exception("Can't remove, pandemic is null.");
35 }
36 }
37}
Note: See TracBrowser for help on using the repository browser.