Example #1
0
        /// <summary>
        /// 根据ID删除数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool Delete(Array id)
        {
            foreach (var item in id)
            {
                int ID = Convert.ToInt32(item);
                //先查
                AdminInfo entity = adminInfoDAL.LoadEntities(u => u.ID == ID).FirstOrDefault();
                //1.1、获取用户拥有的所有角色
                List <R_UserInfo_RoleInfo> list = r_UserInfo_RoleInfoDAL.LoadEntities(u => u.AdminID == entity.AdminID).ToList();
                //for 循环打上删除标记
                for (int i = 0; i < list.Count; i++)
                {
                    r_UserInfo_RoleInfoDAL.DeleteFlag(list[i]);
                }
                if (entity != null)
                {
                    //打标记
                    adminInfoDAL.DeleteFlag(entity);
                }
            }

            if (unitOfWork.SaveChanges() > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }