Ejemplo n.º 1
0
        /// <summary>
        /// 删除用户角色
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="roleId"></param>
        /// <param name="modifier"></param>
        public void DeleteUserRole(Guid userId, Guid roleId, Guid modifier)
        {
            var user_role = _dbContext.Sys_UserRole.FirstOrDefault(o => o.RoleId == roleId && o.UserId == userId);

            if (user_role == null)
            {
                return;
            }

            string oldLog = JsonConvert.SerializeObject(user_role);

            _dbContext.Sys_UserRole.Remove(user_role);
            _dbContext.SaveChanges();

            _activityLogService.DeletedEntity <Entities.Sys_UserRole>(user_role, oldLog, null, modifier);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 删除用户,删除后最好调用强制下线操作
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="modifier"></param>
        public void Delete(Guid userId, Guid modifier)
        {
            var user = _dbContext.Sys_User.Find(userId);

            if (user == null)
            {
                return;
            }

            string oldJson = JsonConvert.SerializeObject(user);

            user.DeletedTime = DateTime.Now;
            user.IsDeleted   = true;
            _dbContext.SaveChanges();

            string newJson = JsonConvert.SerializeObject(user);

            _activityLogService.DeletedEntity <Entities.Sys_User>(userId, oldJson, newJson, modifier);
            RemoveCache(user.Id);
        }