/// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="userID">要删除的用户编号</param>
        /// <returns>是否成功</returns>
        public bool Delete(int userID)
        {
            var userElements = UserInfoModuleElementRepository
                               .LoadEntities(s => s.UserInfo.ID == userID)
                               .ToArray();

            foreach (var item in userElements)
            {
                UserInfoModuleElementRepository.DeleteEntity(item);
            }
            UserInfo user = UserInfoRepository.LoadFirst(u => u.ID == userID);

            CurrentRepository.DeleteEntity(user);
            return(CurrentContext.SaveChanges() > 0);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 删除指定模块
 /// </summary>
 /// <param name="module">要删除的模块</param>
 /// <returns>是否成功</returns>
 public bool DelectModule(Module module)
 {
     RoleModuleElement[] roleElements = RoleModuleElementRepository
                                        .LoadEntities(e => e.Module.ID == module.ID)
                                        .ToArray();
     UserInfoModuleElement[] userElements = UserInfoModuleElementRepository
                                            .LoadEntities(e => e.Module.ID == module.ID)
                                            .ToArray();
     foreach (RoleModuleElement item in roleElements)
     {
         RoleModuleElementRepository.DeleteEntity(item);
     }
     foreach (UserInfoModuleElement item in userElements)
     {
         UserInfoModuleElementRepository.DeleteEntity(item);
     }
     module.ModuleElementModules.Clear();
     module.RoleModules.Clear();
     module.ModuleUserInfos.Clear();
     CurrentRepository.DeleteEntity(module);
     return(CurrentContext.SaveChanges() > 0);
 }