コード例 #1
0
        public async Task <GetCustomerVehicleResponse> GetCustomerVehicle(int customerNo, int vehicleNo, DealerConfigurationResponse dealerConfigResponse)
        {
            if (dealerConfigResponse == null)
            {
                throw new ArgumentNullException(nameof(dealerConfigResponse));
            }
            if (customerNo <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(customerNo));
            }
            if (vehicleNo <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(vehicleNo));
            }

            var customer = _customerVehicleDal.GetCustomer(customerNo, dealerConfigResponse.RooftopId, dealerConfigResponse.CommunityId);

            if (customer == null)
            {
                return(null);
            }

            var customerVehicle = _customerVehicleDal.GetCustomerVehicle(customer.Id, vehicleNo);

            if (customerVehicle == null)
            {
                return(null);
            }

            if (!_customerInvitationService.ValidateLink(customerVehicle))
            {
                throw new InvitationExpiredException();
            }

            var getCustomerVehicleResponse = _mapper.Map <Customer, GetCustomerVehicleResponse>(customer);

            _mapper.Map(customerVehicle, getCustomerVehicleResponse);

            var verifyCustomerResponse = await _customerRegistrationService.Verify(customer);

            getCustomerVehicleResponse.CdkAutolineToken = verifyCustomerResponse.CDKAutolineToken;
            getCustomerVehicleResponse.CustomerLoginId  = verifyCustomerResponse.CustomerLoginId;
            return(getCustomerVehicleResponse);
        }