public static void Add(Employee employee) { using (var context = new SoftUniEntities()) { context.Employees.Add(employee); context.SaveChanges(); } }
public static void Modify(Employee employee) { using (var context = new SoftUniEntities()) { context.Employees.Attach(employee); context.Entry(employee).State = EntityState.Modified; context.SaveChanges(); } }
public static void Delete(Employee employee) { using (var context = new SoftUniEntities()) { context.Employees.Attach(employee); context.Employees.Remove(employee); context.SaveChanges(); } }
public void Add() { var gandolf = new Employee() { FirstName = "Gandolf", LastName = "Thegray", JobTitle = "Network Administrator", DepartmentID = 11, HireDate = new DateTime(2001, 03, 27), Salary = 32500 }; EmployeeDao.Add(gandolf); this.employee = gandolf; Assert.IsNotNull(gandolf.EmployeeID); }