public async Task SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken) { if (userData == null) { throw new ArgumentNullException("userData"); } if (item == null) { throw new ArgumentNullException("item"); } if (userId == Guid.Empty) { throw new ArgumentNullException("userId"); } cancellationToken.ThrowIfCancellationRequested(); var keys = item.GetUserDataKeys(); foreach (var key in keys) { try { await Repository.SaveUserData(userId, key, userData, cancellationToken).ConfigureAwait(false); var newValue = userData; lock (_userData) { _userData[GetCacheKey(userId, key)] = newValue; } } catch (Exception ex) { _logger.ErrorException("Error saving user data", ex); throw; } } EventHelper.FireEventIfNotNull(UserDataSaved, this, new UserDataSaveEventArgs { Keys = keys, UserData = userData, SaveReason = reason, UserId = userId, Item = item }, _logger); }
public async Task SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken) { if (userData == null) { throw new ArgumentNullException("userData"); } if (item == null) { throw new ArgumentNullException("item"); } if (userId == Guid.Empty) { throw new ArgumentNullException("userId"); } cancellationToken.ThrowIfCancellationRequested(); var keys = item.GetUserDataKeys(); foreach (var key in keys) { await Repository.SaveUserData(userId, key, userData, cancellationToken).ConfigureAwait(false); } var cacheKey = GetCacheKey(userId, item.Id); _userData.AddOrUpdate(cacheKey, userData, (k, v) => userData); EventHelper.FireEventIfNotNull(UserDataSaved, this, new UserDataSaveEventArgs { Keys = keys, UserData = userData, SaveReason = reason, UserId = userId, Item = item }, _logger); }
public UserItemData GetUserData(Guid userId, IHasUserData item) { return GetUserData(userId, item.Id, item.GetUserDataKeys()); }
public UserItemData GetUserData(Guid userId, IHasUserData item) { return(GetUserData(userId, item.Id, item.GetUserDataKeys())); }