public Department GetDept(int deptId)
 {
     using (var _deptContext = new DataContext())
     {
         return _deptContext.Department.Where(x => x.DeptID == deptId).SingleOrDefault();
     }
 }
 public void SaveDept(Department dept)
 {
     using (var _deptContext = new DataContext())
     {
         _deptContext.Department.Add(dept);
         _deptContext.SaveChanges();
     }
 }
 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();
     }
 }
        public IEnumerable<Department> DeptRepo()
        {
            using (var _deptContext = new DataContext())
            {
                var data = _deptContext.Department;
                var retVal = data.ToList();
                return retVal;

            }
        }
 public void DeleteDept(int deptId)
 {
     var deptToDelete = GetDept(deptId);
     if (null != deptToDelete)
     {
         using (var _deptContext = new DataContext())
         {
             _deptContext.Department.Remove(deptToDelete);
             _deptContext.SaveChanges();
         }
     }
 }
Beispiel #6
0
 public EmployeeManager()
 {
     empContext = new DataContext();
 }