Created
January 2, 2021 06:52
-
-
Save JIOO-phoeNIX/f31ef9d7e85b08ebbb2f596a84bdbb50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using GraphQLSampleApp.DataAccess.Entity; | |
using Microsoft.EntityFrameworkCore; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace GraphQLSampleApp.DataAccess.DAO | |
{ | |
public class DepartmentRepository | |
{ | |
private readonly SampleAppDbContext _sampleAppDbContext; | |
public DepartmentRepository(SampleAppDbContext sampleAppDbContext) | |
{ | |
_sampleAppDbContext = sampleAppDbContext; | |
} | |
public List<Department> GetAllDepartmentOnly() | |
{ | |
return _sampleAppDbContext.Department.ToList(); | |
} | |
public List<Department> GetAllDepartmentsWithEmployee() | |
{ | |
return _sampleAppDbContext.Department | |
.Include(d => d.Employees) | |
.ToList(); | |
} | |
public async Task<Department> CreateDepartment(Department department) | |
{ | |
await _sampleAppDbContext.Department.AddAsync(department); | |
await _sampleAppDbContext.SaveChangesAsync(); | |
return department; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment