public int Update(Employee item) { using (var context = new StarTed()) { context.Entry(item).State = System.Data.Entity.EntityState.Modified; return(context.SaveChanges()); } }
public int Add(Employee item) { using (var context = new StarTed()) { context.Employees.Add(item); context.SaveChanges(); return(item.EmployeeID); } }
public int Delete(int employeeid) { using (var context = new StarTed()) { var existing = context.Employees.Find(employeeid); if (existing == null) { throw new Exception("Employee has been removed from database"); } context.Employees.Remove(existing); return(context.SaveChanges()); } }