示例#1
0
        private async Task <Result <HireResponse> > BikeAndClientValidationAsync(CreateHireCommand request)
        {
            Exception exception = new ();

            var bikeCheck = await _bikeService.CheckIfBikeAvailableAsync(request.BikeId);

            if (bikeCheck.IsFaulted)
            {
                var result = bikeCheck.IfFail(f => exception = f);
                return(new Result <HireResponse>(exception));
            }

            var clientCheck = await _clientService.CheckIfClientAvailableAsync(request.ClientId);

            if (clientCheck.IsFaulted)
            {
                var result = clientCheck.IfFail(f => exception = f);
                return(new Result <HireResponse>(exception));
            }

            return(new Result <HireResponse>(new HireResponse()));
        }