public async Task <IEnumerable <ParticipantBetQueryResult> > ExecuteAsync(ParticipantBetQuery query)
        {
            Guid userId = _principalProvider.Get().GetUserId();

            if (query.GameId.HasValue)
            {
                var result = new[] { await _betReader.GetByUserIdAndGameId(query.GameId.Value, userId) };
                return(ToQueryResult(result));
            }

            return(ToQueryResult(await _betReader.GetByUserId(userId)));
        }
        public async Task ExecuteAsync(UpdateUserProfileCommand command)
        {
            Guid userId = _principalProvider.Get().GetUserId();
            User user   = await _userUpdater.GetAsync(userId);

            user.FirstName = command.FirstName;
            user.LastName  = command.LastName;
            user.Email     = command.Email; // No duplicates allowed. Enforced by an index.
            user.Nickname  = command.Nickname;

            await _userUpdater.UpdateAsync(user);
        }
예제 #3
0
        public async Task <Profile> ExecuteAsync(UserProfileQuery query)
        {
            Guid userId = _principalProvider.Get().GetUserId();
            User result = await _userReader.ByIdAsync(userId);

            var profile = new Profile
            {
                Id        = result.Id,
                FirstName = result.FirstName,
                LastName  = result.LastName,
                Email     = result.Email,
                Nickname  = result.Nickname,
                IsAdmin   = result.Roles?.Contains(UserRoles.Administrator) ?? false
            };

            return(profile);
        }
        public Task ExecuteAsync(ParticipantBetCommand command)
        {
            Guid userId = _principalProvider.Get().GetUserId();

            return(UpsertBetIfValid(command, userId));
        }