ScientificReport
FacultyReportRepository.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 FacultyReportRepository: IRepository<FacultyReport>
12  {
13  private readonly ScientificReportDbContext _context;
14 
16  {
17  _context = context;
18  }
19 
20  public virtual IEnumerable<FacultyReport> All()
21  {
22  return _context.FacultyReports
23  .Include(b => b.DepartmentReports);
24  }
25 
26  public virtual IEnumerable<FacultyReport> AllWhere(Func<FacultyReport, bool> predicate)
27  {
28  return All().Where(predicate);
29  }
30 
31  public virtual FacultyReport Get(Guid id)
32  {
33  return All().FirstOrDefault(u => u.Id == id);
34  }
35 
36  public virtual FacultyReport Get(Func<FacultyReport, bool> predicate)
37  {
38  return All().Where(predicate).FirstOrDefault();
39  }
40 
41  public virtual void Create(FacultyReport item)
42  {
43  _context.FacultyReports.Add(item);
44  _context.SaveChanges();
45  }
46 
47  public virtual void Update(FacultyReport item)
48  {
49  if (item != null)
50  {
51  _context.FacultyReports.Update(item);
52  _context.SaveChanges();
53  }
54  }
55 
56  public virtual void Delete(Guid id)
57  {
58  var item = _context.FacultyReports.Find(id);
59  if (item != null)
60  {
61  _context.FacultyReports.Remove(item);
62  _context.SaveChanges();
63  }
64  }
65 
66  public virtual IQueryable<FacultyReport> GetQuery()
67  {
68  return _context.FacultyReports;
69  }
70  }
71 }
virtual IEnumerable< FacultyReport > AllWhere(Func< FacultyReport, bool > predicate)
virtual FacultyReport Get(Func< FacultyReport, bool > predicate)