Exemple #1
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());
        }
Exemple #2
0
        public async Task <Automobile> GetAutomobileAsync(int theAutomobileId)
        {
            var aDto =
                await ConnectionAsync.Table <AutomobileDTO>().Where(aItem => aItem.Id == theAutomobileId).FirstOrDefaultAsync();

            return(aDto?.ToEntity());
        }
Exemple #3
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());
        }
Exemple #4
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());
        }
Exemple #5
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());
        }
Exemple #6
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());
        }
Exemple #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);
        }
Exemple #8
0
        public async Task <Customer> GetCustomerByNameAsync(string theCustomerName)
        {
            var aCustomer = await ConnectionAsync.Table <CustomerDTO>().FirstOrDefaultAsync(aItem => aItem.Name == theCustomerName);

            return(aCustomer?.ToEntity());
        }
Exemple #9
0
 public async Task <int> AddCustomerAsync(Customer theCustomer)
 {
     return(await ConnectionAsync.InsertAsync(theCustomer.ToDTO()));
 }
Exemple #10
0
        public async Task <Driver> GetDriverAsync(int theDriverId)
        {
            var aDriver = await ConnectionAsync.Table <DriverDTO>().Where(aItem => aItem.Id == theDriverId).FirstOrDefaultAsync();

            return(aDriver?.ToEntity());
        }
 public async Task UpdateRentalAgreementAsync(RentalAgreement theRentalAgreement)
 {
     await ConnectionAsync.UpdateAsync(theRentalAgreement);
 }
Exemple #12
0
 public async Task DeleteLocationAsync(Location theLocation)
 {
     await ConnectionAsync.DeleteAsync(theLocation.ToDTO());
 }
Exemple #13
0
 public async Task <int> AddLocationAsync(Location theLocation)
 {
     return(await ConnectionAsync.InsertAsync(theLocation.ToDTO()));
 }
 public async Task DeleteUserAsync(User theUser)
 {
     await ConnectionAsync.DeleteAsync(theUser.ToDTO());
 }
Exemple #15
0
 public async Task DeleteAutomobileAsync(Automobile theAutomobile)
 {
     await ConnectionAsync.DeleteAsync(theAutomobile.ToDTO());
 }
        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()));
        }
 public async Task UpdateUserAsync(User theUser)
 {
     await ConnectionAsync.UpdateAsync(theUser.ToDTO());
 }
        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 DeleteRentalAgreementAsync(RentalAgreement theRentalAgreement)
 {
     await ConnectionAsync.DeleteAsync(theRentalAgreement);
 }
Exemple #21
0
 public async Task <int> AddDriverAsync(Driver theDriver)
 {
     return(await ConnectionAsync.InsertAsync(theDriver.ToDTO()));
 }
Exemple #22
0
        public async Task <Customer> GetCustomerAsync(int theCustomerId)
        {
            var aCustomer = await ConnectionAsync.Table <CustomerDTO>().FirstOrDefaultAsync(aItem => aItem.Id == theCustomerId);

            return(aCustomer?.ToEntity());
        }
Exemple #23
0
 public async Task DeleteDriverAsync(Driver theDriver)
 {
     await ConnectionAsync.DeleteAsync(theDriver.ToDTO());
 }
        public async Task <RentalAgreement> GetRentalAgreementAsync(int theRentalAgreementId)
        {
            var aRentalAgreement = await ConnectionAsync.Table <RentalAgreementDTO>().Where(aItem => aItem.Id == theRentalAgreementId).FirstOrDefaultAsync();

            return(aRentalAgreement?.ToEntity());
        }
Exemple #25
0
        public async Task <Location> GetLocationAsync(int theLocationId)
        {
            var aLocation = await ConnectionAsync.Table <LocationDTO>().Where(aItem => aItem.Id == theLocationId).FirstOrDefaultAsync();

            return(aLocation?.ToEntity());
        }
Exemple #26
0
 public async Task DeleteCustomerAsync(Customer theCustomer)
 {
     await ConnectionAsync.DeleteAsync(theCustomer.ToDTO());
 }
Exemple #27
0
 public async Task UpdateLocationAsync(Location theLocation)
 {
     await ConnectionAsync.UpdateAsync(theLocation.ToDTO());
 }
Exemple #28
0
 public async Task <int> AddAutomobileAsync(Automobile theAutomobile)
 {
     return(await ConnectionAsync.InsertAsync(theAutomobile.ToDTO()));
 }
 public async Task DeleteRenterAsync(Renter theRenter)
 {
     await ConnectionAsync.DeleteAsync(theRenter.ToDTO());
 }
 public async Task <int> AddRentalAgreementAsync(RentalAgreement theRentalAgreement)
 {
     return(await ConnectionAsync.InsertAsync(theRentalAgreement));
 }