public static void TestOperations() { var context = new SoftUniEntities(); Employee employee = new Employee() { FirstName = "Denis1", LastName = "Neychev", JobTitle = "Zidaro-mazach", DepartmentID = 1, ManagerID = 6, HireDate = DateTime.Now, Salary = 999 }; Employee.Add(employee); context.SaveChanges(); Console.WriteLine(employee.EmployeeID); employee.FirstName = employee.FirstName + '.'; Employee.Modify(employee); context.SaveChanges(); Employee.Delete(employee); context.SaveChanges(); }
public static void Add(Employee employee) { var context = new SoftUniEntities(); context.Employees.Add(employee); context.SaveChanges(); }
public static void Modify(Employee employee) { var context = new SoftUniEntities(); Employee EmpModify = context.Employees.Find(employee.EmployeeID); context.Entry(EmpModify).CurrentValues.SetValues(employee); context.SaveChanges(); }
public static void Delete(Employee employee) { var context = new SoftUniEntities(); var entry = context.Entry(employee); if (entry.State == EntityState.Detached) { context.Employees.Attach(employee); } context.Employees.Remove(employee); context.SaveChanges(); }