コード例 #1
0
        public void DeleteUserAuthentications(User user, DeviceController device)
        {
            if (user == null || device == null)
            {
                return;
            }
            if (user.UserAuthentications == null || user.UserAuthentications.Count == 0)
            {
                return;
            }

            Log.Info("Getting user authentication infos...");
            var userAuthenticationsOfDevice = user.UserAuthentications.Where(a => a.DeviceID == device.DeviceID);
            var authenticationsOfDevice     = userAuthenticationsOfDevice as IList <UserAuthentication> ?? userAuthenticationsOfDevice.ToList();

            Log.InfoFormat("Deleting user authentication, UserId={0}, DeviceId={1}.", user.UserID, device.DeviceID);
            authenticationsOfDevice.ForEach(x =>
            {
                _userAuthenticationRepo.Delete(x.UserAuthenticationID);
                Log.InfoFormat("User authentication id={0} deleted", x.UserAuthenticationID);
            });

            _userEventRepo.Insert(new UserEvent()
            {
                EventType    = UserEventType.Modify,
                UserID       = user.UserID,
                CreateDate   = DateTime.Now,
                CreateUserID = GlobalSetting.DeviceSystemId,
                IsFinished   = true,
                EventData    = "Delete user authentications by sync system user operation",
            });
        }