Пример #1
0
 public void SaveDept(Department dept)
 {
     using (var _deptContext = new DataContext())
     {
         _deptContext.Department.Add(dept);
         _deptContext.SaveChanges();
     }
 }
Пример #2
0
 public void EditDept(Department deptToEdit)
 {
     using (var _deptContext = new DataContext())
     {
         var selectedDEpt = _deptContext.Department.Where(x => x.DeptID == deptToEdit.DeptID).SingleOrDefault();
         selectedDEpt.DeptName = deptToEdit.DeptName;
         _deptContext.SaveChanges();
     }
 }
Пример #3
0
 public void DeleteDept(int deptId)
 {
     var deptToDelete = GetDept(deptId);
     if (null != deptToDelete)
     {
         using (var _deptContext = new DataContext())
         {
             _deptContext.Department.Remove(deptToDelete);
             _deptContext.SaveChanges();
         }
     }
 }