public async Task Handle(HistoryUpdatedIntegrationEvent @event) { var userStatistics = await _recommendationRepository.GetUserStatistics(@event.UserId, @event.ProfileId); if (userStatistics == null) { var newUserStatistics = new UserStatisticsEntity() { PartitionKey = @event.UserId, RowKey = @event.ProfileId, GenresPreferences = $"{@event.Genres}:1", RelaseYearPreferences = $"{@event.ReleaseYear}:1", VideoIdPreferences = @event.WatchingItemId }; await _recommendationRepository.AddUserStatistics(newUserStatistics); } else { var genreDictionary = userStatistics.GenresPreferences.ConvertToDictionary(); var releaseYearDictionary = userStatistics.RelaseYearPreferences.ConvertToDictionary(); IncrementValue(genreDictionary, @event.Genres); IncrementValue(releaseYearDictionary, @event.ReleaseYear); userStatistics.GenresPreferences = genreDictionary.ConvertToString(); userStatistics.RelaseYearPreferences = releaseYearDictionary.ConvertToString(); userStatistics.VideoIdPreferences = userStatistics.VideoIdPreferences + "," + @event.WatchingItemId; await _recommendationRepository.UpdateUserStatistics(userStatistics); } }
public Dictionary <string, User> GetRegisteredUsers() { List <UserEntity> userEntitiesList = db.GetRegisteredUsers(); List <UserStatisticsEntity> userStatEntitiesList = db.GetAllUserStatistics(); Dictionary <string, User> registeredUsers = new Dictionary <string, User>(); for (int i = 0; i < userEntitiesList.Count; i++) { UserEntity ue = userEntitiesList[i]; UserStatisticsEntity use = userStatEntitiesList[i]; User user = new User(ue.Username, ue.Password, ue.Email, ue.Money); user.Stats.Points = use.Points; user.Stats.AvgCashGain = use.AvgCashGain; user.Stats.AvgGrossProfit = use.AvgGrossProfit; user.Stats.HighestCashGain = use.HighestCashGain; user.Stats.NumOfGames = use.NumOfGames; user.Stats.TotalGrossProfit = use.TotalGrossProfit; registeredUsers.Add(user.Username, user); } return(registeredUsers); }