コード例 #1
0
        public async Task <IEnumerable <Automobile> > GetAutomobilesForLocationAsync(int theCustomerId, int theLocationId)
        {
            var aCustomerLocations = await _locationRepository.GetLocationsForCustomerAsync(theCustomerId);

            if (aCustomerLocations == null)
            {
                throw new ApplicationException("Customer has no locations");
            }

            if (aCustomerLocations.All(aItem => aItem.Id != theLocationId))
            {
                throw new ApplicationException("Customer has no locations with this id");
            }

            return(await _autoRepository.GetAutomobilesForLocationAsync(theLocationId));
        }