예제 #1
0
 public void DeleteDepartment(DepartmentModel department)
 {
     using (geekinsidekmsEntities context =
        new geekinsidekmsEntities())
     {
         Department dbDept = (from d in context.Departments
                              where d.Id == department.Id
                              select d).FirstOrDefault();
         if (dbDept != null)
         {
             context.Departments.DeleteObject(dbDept);
             context.SaveChanges();
         }
     }
 }
예제 #2
0
 public int CreateDepartment(DepartmentModel department)
 {
     using (geekinsidekmsEntities context =
         new geekinsidekmsEntities())
     {
         Department dbDepartment = new Department
         {
             DepartmentName = department.DepartmentName,
             FolderId = department.FolderId
         };
         context.Departments.AddObject(dbDepartment);
         context.SaveChanges();
         return dbDepartment.Id;
     }
 }
예제 #3
0
 public void UpdateDepartment(DepartmentModel department)
 {
     using (geekinsidekmsEntities context =
        new geekinsidekmsEntities())
     {
         Department dbDepartment = new Department
         {
             Id = department.Id,
             DepartmentName = department.DepartmentName,
             FolderId = department.FolderId
         };
         context.Departments.AddObject(dbDepartment);
         context.ObjectStateManager.ChangeObjectState(dbDepartment, EntityState.Modified);
         context.SaveChanges();
     }
 }
예제 #4
0
        // 添加部门
        public void CreateDepartment(string deptName, string folderDesc)
        {
            FolderModel deptFolder = new FolderModel
            {
                FolderName = deptName,
                Description = folderDesc,
                ParentFolderId = 0, // 1级目录
                PhysicalPath = Helper.CreateNewFolderPath(@"\") // 1级目录存放在根目录下
            };
            Helper.CreateDirectory(deptFolder.PhysicalPath);    // 创建目录

            int folderId = folderDAL.CreateFolder(deptFolder);

            DepartmentModel dept = new DepartmentModel
            {
                DepartmentName = deptName,
                FolderId = folderId
            };
            departmentDAL.CreateDepartment(dept);
        }
예제 #5
0
 // 更新部门信息
 public void UpdateDepartment(DepartmentModel dept)
 {
     departmentDAL.UpdateDepartment(dept);
 }