Пример #1
0
        public UserWithinDistanceCommandHandlerConfigurator WithUsersInCityResultException(Exception exception)
        {
            this.userRepository
            .Setup(x => x.GetUsersInCityAsync(It.IsAny <string>()))
            .ReturnsAsync(GetUsersInCityResult.Failure(exception));

            return(this);
        }
Пример #2
0
        public async Task <GetUsersInCityResult> GetUsersInCityAsync(string city)
        {
            var result = await this.userApi.GetUsersInCityAsync(city);

            if (result.IsSuccess)
            {
                var mappedUsers = result
                                  .Users
                                  .Select(
                    user => new User(
                        user.Id,
                        user.FirstName,
                        user.LastName,
                        user.Email,
                        user.IpAddress,
                        new Coordinate(user.Latitude, user.Longitude)));

                return(GetUsersInCityResult.Success(mappedUsers));
            }

            return(GetUsersInCityResult.Failure(result.Exception));
        }