ScientificReport
ConferenceRepository.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using Microsoft.EntityFrameworkCore;
8 
9 namespace ScientificReport.DAL.Repositories
10 {
11  public class ConferenceRepository : IRepository<Conference>
12  {
13  private readonly ScientificReportDbContext _context;
14 
16  {
17  _context = context;
18  }
19 
20  public virtual IEnumerable<Conference> All()
21  {
22  return _context.Conferences;
23  }
24 
25  public virtual IEnumerable<Conference> AllWhere(Func<Conference, bool> predicate)
26  {
27  return All().Where(predicate);
28  }
29 
30  public virtual Conference Get(Guid id)
31  {
32  return All().FirstOrDefault(u => u.Id == id);
33  }
34 
35  public virtual Conference Get(Func<Conference, bool> predicate)
36  {
37  return All().Where(predicate).FirstOrDefault();
38  }
39 
40  public virtual void Create(Conference item)
41  {
42  _context.Conferences.Add(item);
43  _context.SaveChanges();
44  }
45 
46  public virtual void Update(Conference item)
47  {
48  if (item == null) return;
49  _context.Conferences.Update(item);
50  _context.SaveChanges();
51  }
52 
53  public virtual void Delete(Guid id)
54  {
55  var item = _context.Conferences.Find(id);
56  if (item == null)
57  {
58  return;
59  }
60 
61  _context.Conferences.Remove(item);
62  _context.SaveChanges();
63  }
64 
65  public virtual IQueryable<Conference> GetQuery()
66  {
67  return _context.Conferences;
68  }
69  }
70 }
virtual IEnumerable< Conference > AllWhere(Func< Conference, bool > predicate)
virtual Conference Get(Func< Conference, bool > predicate)