Пример #1
0
 public Employee FindByPKID(int EmployeeID)
 {
     using (var context = new StarTed())
     {
         return(context.Employees.Find(EmployeeID));
     }
 }
Пример #2
0
 public List <Program> List()
 {
     using (var context = new StarTed())
     {
         return(context.Programs.ToList());
     }
 }
Пример #3
0
 public List <Position> List()
 {
     using (var context = new StarTed())
     {
         return(context.Positions.ToList());
     }
 }
Пример #4
0
 public int Update(Employee item)
 {
     using (var context = new StarTed())
     {
         context.Entry(item).State = System.Data.Entity.EntityState.Modified;
         return(context.SaveChanges());
     }
 }
Пример #5
0
 public int Add(Employee item)
 {
     using (var context = new StarTed())
     {
         context.Employees.Add(item);
         context.SaveChanges();
         return(item.EmployeeID);
     }
 }
Пример #6
0
 public List <Employee> FindByPartialName(string partialname)
 {
     using (var context = new StarTed())
     {
         IEnumerable <Employee> results =
             context.Database.SqlQuery <Employee>("Employees_FindByPartialName @PartialName",
                                                  new SqlParameter("PartialName", partialname));
         return(results.ToList());
     }
 }
Пример #7
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());
     }
 }