Created
August 26, 2021 10:31
-
-
Save executeautomation/f9d680f36969826abdeea8338cef07ae to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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