예제 #1
0
        public async Task <Automobile> GetAutomobileAsync(int theAutomobileId)
        {
            var aDto =
                await ConnectionAsync.Table <AutomobileDTO>().Where(aItem => aItem.Id == theAutomobileId).FirstOrDefaultAsync();

            return(aDto?.ToEntity());
        }
예제 #2
0
        public async Task <IEnumerable <Automobile> > GetAutomobilesAsync(IEnumerable <int> theAutomobileIds)
        {
            var aResult =
                await ConnectionAsync.Table <AutomobileDTO>().Where(aItem => theAutomobileIds.Contains(aItem.Id)).ToListAsync();

            return(aResult.Select(aItem => aItem.ToEntity()).ToList());
        }
예제 #3
0
        public async Task <IEnumerable <Driver> > GetDriverByLastNameAsync(string theDriverName)
        {
            var aResult = await ConnectionAsync.Table <DriverDTO>().Where(aItem => aItem.LastName.Contains(theDriverName)).ToListAsync();

            // if there are no results return an empty list
            if (aResult == null || !aResult.Any())
            {
                return(Enumerable.Empty <Driver>().ToList());
            }

            return(aResult.Select(aItem => aItem.ToEntity()).ToList());
        }
예제 #4
0
        public async Task <IEnumerable <Driver> > GetDriversByCustomerAsync(int theCustomerId)
        {
            var aResult = await ConnectionAsync.Table <DriverDTO>().Where(aItem => aItem.CustomerId == theCustomerId).ToListAsync();

            // if there are no results return an empty list
            if (aResult == null || !aResult.Any())
            {
                return(Enumerable.Empty <Driver>().ToList());
            }

            return(aResult.Select(aItem => aItem.ToEntity()).ToList());
        }
예제 #5
0
        public async Task <IEnumerable <Location> > GetLocationsForCustomerAsync(int theCustomerId)
        {
            var aLocations = ConnectionAsync.Table <LocationDTO>().Where(aItem => aItem.CustomerId == theCustomerId);

            if (aLocations == null)
            {
                return(Enumerable.Empty <Location>());
            }

            var aLocationList = await aLocations.ToListAsync();

            return(aLocationList?.Select(aItem => aItem.ToEntity()).ToList());
        }
예제 #6
0
        public async Task <IEnumerable <Automobile> > GetAutomobilesForLocationAsync(int theLocationId)
        {
            var aQueryResult = ConnectionAsync.Table <AutomobileDTO>().Where(aItem => aItem.LocationId == theLocationId);

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

            var aDtoList = await aQueryResult.ToListAsync();

            return(aDtoList?.Select(aItem => aItem.ToEntity()).ToList());
        }
예제 #7
0
        /// <summary>
        /// Gets all completed task async.
        /// </summary>
        /// <returns>The all completed task async.</returns>
        /// <param name="token">Token.</param>
        public async Task <IList <TodoItem> > GetAllCompletedTaskAsync(CancellationToken?token = null)
        {
            if (token.HasValue)
            {
                token.Value.ThrowIfCancellationRequested();
            }

            IList <TodoItem> items = await ConnectionAsync.Table <TodoItem>().
                                     Where(x => x.Status == StatusType.Completed).
                                     OrderByDescending(x => x.LastModified).
                                     ToListAsync().ConfigureAwait(false);

            return(items);
        }
예제 #8
0
        public async Task <Location> GetLocationAsync(int theLocationId)
        {
            var aLocation = await ConnectionAsync.Table <LocationDTO>().Where(aItem => aItem.Id == theLocationId).FirstOrDefaultAsync();

            return(aLocation?.ToEntity());
        }
예제 #9
0
        public async Task <Driver> GetDriverAsync(int theDriverId)
        {
            var aDriver = await ConnectionAsync.Table <DriverDTO>().Where(aItem => aItem.Id == theDriverId).FirstOrDefaultAsync();

            return(aDriver?.ToEntity());
        }
예제 #10
0
        public async Task <IEnumerable <User> > GetUsersForCustomerAsync(int theCustomerId)
        {
            var aUser = await ConnectionAsync.Table <UserDTO>().Where(aItem => aItem.CustomerId == theCustomerId).ToListAsync();

            return(aUser?.Select(aItem => aItem.ToEntity()));
        }
예제 #11
0
        public async Task <User> GetUserByEmailAsync(string theEmail)
        {
            var aUser = await ConnectionAsync.Table <UserDTO>().Where(aItem => aItem.Email == theEmail).FirstOrDefaultAsync();

            return(aUser?.ToEntity());
        }
        public async Task <IEnumerable <RentalAgreement> > GetRentalAgreementsForCustomerAsync(int theCustomerId)
        {
            var aRentalAgreement = await ConnectionAsync.Table <RentalAgreementDTO>().Where(aItem => aItem.CustomerId == theCustomerId).ToListAsync();

            return(aRentalAgreement.Select(aItem => aItem.ToEntity()).ToList());
        }
        public async Task <RentalAgreement> GetRentalAgreementAsync(int theRentalAgreementId)
        {
            var aRentalAgreement = await ConnectionAsync.Table <RentalAgreementDTO>().Where(aItem => aItem.Id == theRentalAgreementId).FirstOrDefaultAsync();

            return(aRentalAgreement?.ToEntity());
        }
예제 #14
0
        public async Task <Customer> GetCustomerByNameAsync(string theCustomerName)
        {
            var aCustomer = await ConnectionAsync.Table <CustomerDTO>().FirstOrDefaultAsync(aItem => aItem.Name == theCustomerName);

            return(aCustomer?.ToEntity());
        }
예제 #15
0
        public async Task <Customer> GetCustomerAsync(int theCustomerId)
        {
            var aCustomer = await ConnectionAsync.Table <CustomerDTO>().FirstOrDefaultAsync(aItem => aItem.Id == theCustomerId);

            return(aCustomer?.ToEntity());
        }