48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using Marco.Pms.DataAccess.Data;
|
|
using Marco.Pms.DataAccess.Repository;
|
|
using Marco.Pms.DataAccess.Repository.IRepository;
|
|
using Marco.Pms.Model.Employees;
|
|
using Marco.Pms.Model.Projects;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System.Linq.Expressions;
|
|
using System.Linq;
|
|
|
|
namespace BulkyBook.DataAccess.Repository
|
|
{
|
|
public class EmployeeRepository : Repository<Employee>, IEmployeeRepository
|
|
{
|
|
private readonly ApplicationDbContext _context;
|
|
public EmployeeRepository(ApplicationDbContext db) : base(db)
|
|
{
|
|
_context = db;
|
|
}
|
|
|
|
|
|
public void Update(Employee employee)
|
|
{
|
|
_context.Employees.Update(employee);
|
|
}
|
|
|
|
public Task<List<Employee>> GetAsync(Expression<Func<Employee, bool>>? filter = null, string? includeProperties = null)
|
|
{
|
|
|
|
IQueryable<Employee> query = _context.Employees;
|
|
if (filter != null)
|
|
{
|
|
query.Where(filter);
|
|
}
|
|
if (!string.IsNullOrEmpty(includeProperties))
|
|
{
|
|
foreach (var includeProp in includeProperties.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
|
{
|
|
query = query.Include(includeProp);
|
|
}
|
|
}
|
|
return query.ToListAsync();
|
|
|
|
|
|
// return await _context.Projects.ToListAsync(); ;
|
|
}
|
|
}
|
|
}
|