Ejemplo n.º 1
0
 public int Update(Employee item)
 {
     using (var context = new StarTed())
     {
         context.Entry(item).State = System.Data.Entity.EntityState.Modified;
         return(context.SaveChanges());
     }
 }
Ejemplo n.º 2
0
 public int Add(Employee item)
 {
     using (var context = new StarTed())
     {
         context.Employees.Add(item);
         context.SaveChanges();
         return(item.EmployeeID);
     }
 }
Ejemplo n.º 3
0
 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());
     }
 }