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