public async Task <GetUserResult> GetUser(GetUserRequest request, CancellationToken token) { var userCursor = await _users.FindAsync(u => u.Login == request.Login && u.Password == request.Password, cancellationToken : token); var user = await userCursor.FirstOrDefaultAsync(token); return(user == null?GetUserResult.Failed() : GetUserResult.Success(user)); }
public async Task <GetUserResult> GetUser(string userId, CancellationToken token) { var userCursor = await _users.FindAsync(u => u.Id == userId, cancellationToken : token); var user = await userCursor.FirstOrDefaultAsync(token); return(user == null?GetUserResult.Failed() : GetUserResult.Success(user)); }
public UserWithinDistanceCommandHandlerConfigurator WithUsers(IEnumerable <User> users) { this.userRepository .Setup(x => x.GetUsersAsync()) .ReturnsAsync(GetUserResult.Success(users)); return(this); }
public async Task <GetUserResult> GetUsersAsync() { var result = await this.userApi.GetUsersAsync(); 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(GetUserResult.Success(mappedUsers)); } return(GetUserResult.Failure(result.Exception)); }