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", }); }
private void DeleteUserMS(User user, DeviceController deviceInfo) { var deviceId = deviceInfo.DeviceID; var deviceUserId = user.UserCode.ToInt32(); Log.Info("Invoke WebSocketOperation..."); var operation = new WebSocketOperation(deviceId); var deleteUserInfoRequest = new DeleteUserInfoRequest() { Token = operation.Token, UserId = deviceUserId }; string rawRequest = DataContractSerializationHelper.Serialize(deleteUserInfoRequest); Log.DebugFormat("Request: {0}", rawRequest); var rawResponse = operation.Execute(rawRequest); Log.DebugFormat("Response: {0}", rawResponse); Log.Info("Deleting UserAuthentications from database..."); var authentications = user.UserAuthentications.FindAll(x => x.DeviceID == deviceId); authentications.ForEach(x => _userAuthenticationRepo.Delete(x.UserAuthenticationID)); }