Skip to content

Instantly share code, notes, and snippets.

@executeautomation
Created August 26, 2021 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save executeautomation/f9d680f36969826abdeea8338cef07ae to your computer and use it in GitHub Desktop.
Save executeautomation/f9d680f36969826abdeea8338cef07ae to your computer and use it in GitHub Desktop.
public class DataRepository : IDataRepository
{
private readonly EmployeeDbContext db;
public DataRepository(EmployeeDbContext db)
{
this.db = db;
}
public List<Employee> GetEmployees() => db.Employee.ToList();
public Employee PutEmployee(Employee employee)
{
db.Employee.Update(employee);
db.SaveChanges();
return db.Employee.Where(x => x.EmployeeId == employee.EmployeeId).FirstOrDefault();
}
public List<Employee> AddEmployee(Employee employee)
{
db.Employee.Add(employee);
db.SaveChanges();
return db.Employee.ToList();
}
public Employee GetEmployeeById(string Id)
{
return db.Employee.Where(x => x.EmployeeId == Id).FirstOrDefault();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment