public async Task <TruckerModel> GetTruckerByUsernameAndPassword(string username, string password) { var channel = GrpcChannel.ForAddress("https://localhost:5003"); try { var client = new Greeter.GreeterClient(channel); var request = new GetTruckerByUsernameAndPasswordRequest(); request.Username = username; request.Password = password; var response = await client.GetTruckersByUsernameAndPasswordAsync(request); if (response.Trucker == null) { return(null); } var trucker = new TruckerModel() { Id = response.Trucker.Id, Username = response.Trucker.Username, TruckingCompany = response.Trucker.TruckingCompany }; return(trucker); } finally { await channel.ShutdownAsync(); } }
public override async Task <GetTruckerByUsernameAndPasswordResponse> GetTruckersByUsernameAndPassword(GetTruckerByUsernameAndPasswordRequest request, ServerCallContext context) { var result = await _truckerQueries.GetTruckerByUsernameAndPassword(request.Username, request.Password); var truckerMessage = new TruckerMessage(); if (result == null) { truckerMessage = null; } else { truckerMessage.Id = result.Id; truckerMessage.Username = result.Username; truckerMessage.Password = result.Password; truckerMessage.TruckingCompany = result.TruckingCompany; } var response = new GetTruckerByUsernameAndPasswordResponse(); response.Trucker = truckerMessage; return(response); }