Example #1
0
        public async Task <UserIndex> Handle(GetUserList request, CancellationToken cancellationToken)
        {
            var userStore = await _userStoreFactory.GetUserStore();

            var results = await userStore.QueryItemsAsync(_ => true, request.Offset, cancellationToken);

            return(new UserIndex(results.UserIds, nextIndex: results.NextOffset, previousIndex: request.Offset));
        }
Example #2
0
        public async Task <CreateUserResult> Handle(CreateUser request, CancellationToken cancellationToken)
        {
            var(userName, contactInfo, dateOfBirth, profileImages) = request;
            var user      = new User(Guid.NewGuid(), userName, contactInfo, dateOfBirth, profileImages);
            var userStore = await _userStoreFactory.GetUserStore();

            var response = await userStore.CreateItemAsync(user, cancellationToken);

            return(new CreateUserResult(response.ETag, user));
        }
Example #3
0
        public async Task <IUserDeleteResult> Handle(DeleteUserById request, CancellationToken cancellationToken)
        {
            var userStore = await _userStoreFactory.GetUserStore();

            var response = await userStore.DeleteItemAsync(request.UserId.ToString(), cancellationToken);

            return(response.StatusCode switch
            {
                HttpStatusCode.NotFound => UserNotFound.Instance,
                _ => await PurgeCdnCache(request.UserId)
            });
Example #4
0
        public async Task <IGetUserResult> Handle(GetUserById request, CancellationToken cancellationToken)
        {
            var userStore = await _userStoreFactory.GetUserStore();

            var response = await userStore.ReadItemAsync(request.UserId.ToString(), request.Etag, cancellationToken);

            return(response.StatusCode switch
            {
                HttpStatusCode.NotModified => UserNotModified.Instance,
                HttpStatusCode.NotFound => UserNotFound.Instance,
                _ => new UserFound(response.ETag, response.User)
            });