ScientificReport
TeacherReportRepository.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 TeacherReportRepository : IRepository<TeacherReport>
12  {
13  private readonly ScientificReportDbContext _context;
14 
16  {
17  _context = context;
18  }
19 
20  public IEnumerable<TeacherReport> All()
21  {
22  return _context.TeacherReports
23  .Include(p => p.Teacher)
24  .Include(p => p.TeacherReportsPublications).ThenInclude(p => p.Publication)
25  .Include(p => p.TeacherReportsArticles).ThenInclude(p => p.Article)
26  .Include(p => p.TeacherReportsReportThesis).ThenInclude(p => p.ReportThesis)
27  .ThenInclude(p => p.Conference)
28  .Include(p => p.TeacherReportsScientificWorks).ThenInclude(p => p.ScientificWork)
29 
30  .Include(p => p.TeacherReportsGrants).ThenInclude(p => p.Grant)
31  .Include(p => p.TeacherReportsScientificInternships).ThenInclude(p => p.ScientificInternship)
32  .Include(p => p.TeacherReportsPostgraduateGuidances).ThenInclude(p => p.PostgraduateGuidance)
33  .Include(p => p.TeacherReportsScientificConsultations).ThenInclude(p => p.ScientificConsultation)
34  .Include(p => p.TeacherReportsPostgraduateDissertationGuidances)
35  .ThenInclude(p => p.PostgraduateDissertationGuidance)
36  .Include(p => p.TeacherReportsReviews).ThenInclude(p => p.Review)
37  .Include(p => p.TeacherReportsOppositions).ThenInclude(p => p.Opposition)
38  .Include(p => p.TeacherReportsPatents).ThenInclude(p => p.Patent)
39  .Include(p => p.TeacherReportsMemberships).ThenInclude(p => p.Membership)
40  ;
41  }
42 
43  public virtual IEnumerable<TeacherReport> AllWhere(Func<TeacherReport, bool> predicate)
44  {
45  return All().Where(predicate);
46  }
47 
48  public virtual TeacherReport Get(Guid id)
49  {
50  return All().FirstOrDefault(u => u.Id == id);
51  }
52 
53  public virtual TeacherReport Get(Func<TeacherReport, bool> predicate)
54  {
55  return All().Where(predicate).FirstOrDefault();
56  }
57 
58  public virtual void Create(TeacherReport item)
59  {
60  _context.TeacherReports.Add(item);
61  _context.SaveChanges();
62  }
63 
64  public virtual void Update(TeacherReport item)
65  {
66  if (item == null) return;
67  _context.TeacherReports.Update(item);
68  _context.SaveChanges();
69  }
70 
71  public virtual void Delete(Guid id)
72  {
73  var item = _context.TeacherReports.Find(id);
74  if (item == null)
75  {
76  return;
77  }
78 
79  _context.TeacherReports.Remove(item);
80  _context.SaveChanges();
81  }
82 
83  public virtual IQueryable<TeacherReport> GetQuery()
84  {
85  return _context.TeacherReports;
86  }
87  }
88 }
virtual IEnumerable< TeacherReport > AllWhere(Func< TeacherReport, bool > predicate)
virtual TeacherReport Get(Func< TeacherReport, bool > predicate)