source: FarmatikoData/FarmatikoRepo/PandemicRepository.cs@ 4e72684

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

Add classes & interfaces for Repo

  • Property mode set to 100644
File size: 890 bytes
Line 
1using FarmatikoData.FarmatikoRepoInterfaces;
2using FarmatikoData.Models;
3using Microsoft.EntityFrameworkCore;
4using System;
5using System.Collections.Generic;
6using System.Linq;
7using System.Text;
8
9namespace FarmatikoData.FarmatikoRepo
10{
11 public class PandemicRepository : IPandemicRepository
12 {
13 private FarmatikoDataContext _context;
14
15 public PandemicRepository(FarmatikoDataContext context)
16 {
17 _context = context;
18 }
19
20 public void Add(Pandemic pandemic)
21 {
22 _context.Pandemics.Add(pandemic);
23 _context.SaveChangesAsync();
24 }
25
26 public IEnumerable<Pandemic> GetAll()
27 {
28 return _context.Pandemics;
29 }
30
31 public void Remove(Pandemic pandemic)
32 {
33 _context.Pandemics.Remove(pandemic);
34 _context.SaveChangesAsync();
35 }
36 }
37}
Note: See TracBrowser for help on using the repository browser.