public async Task <BasicCustomer> addCustomer(BasicCustomer customer) { context.basicCustomers.Add(customer); await context.SaveChangesAsync(); return(customer); }
public async Task <BasicCustomer> addCustomer(string name, DateTime dateOfBirth) { var customer = new BasicCustomer { name = name, dateOfBirth = dateOfBirth }; context.basicCustomers.Add(customer); await context.SaveChangesAsync(); return(customer); }
public async Task <Reservation[]> getReservationsByCustomer(BasicCustomer customer) { var reservations = await(from r in context.reservations where r.customer.id == customer.id && !r.cancelled select r) .Include(res => res.carType) .Include(res => res.customer) .ToArrayAsync(); return(reservations); }
static void initialize() { using (var service = new DatabaseAccessService()) { var customer1 = new BasicCustomer { name = "Linda", dateOfBirth = new DateTime(1990, 1, 1) }; var customer2 = new BasicCustomer { name = "Klas", dateOfBirth = new DateTime(1992, 1, 1) }; service.addCustomer(customer1).Wait(); service.addCustomer(customer2).Wait(); var smallCar = new RentalCarType { carTypeName = "Small car", basePriceModifier = 1, kmPriceModifier = 0 }; var van = new RentalCarType { carTypeName = "Van", basePriceModifier = 1.2, kmPriceModifier = 1 }; var miniBus = new RentalCarType { carTypeName = "Mini bus", basePriceModifier = 1.7, kmPriceModifier = 1.5 }; service.addRentalCarType(smallCar).Wait(); service.addRentalCarType(van).Wait(); service.addRentalCarType(miniBus).Wait(); service.addRentalCar("DDD111", "Small car", 0).Wait(); service.addRentalCar("DDD222", "Small car", 0).Wait(); service.addRentalCar("EEE111", "Van", 0).Wait(); service.addRentalCar("EEE222", "Van", 0).Wait(); service.addRentalCar("FFF111", "Mini bus", 0).Wait(); service.addRentalCar("FFF222", "Mini bus", 0).Wait(); } using (var context = new CarRentalContext()) { RentalRateCalculatorService.setRentalRate(context, 15, 20).Wait(); } Console.WriteLine("Initialize complete"); }
// Example of how the model can be extended static void extendingClass() { using (var databaseAccess = new DatabaseAccessService(new CarRentalContext())) { ModelCustomizer.RegisterModelCustomization( test => { test.Entity <ExtendedCustomer>(); }); var customer = new BasicCustomer { name = "Christie", dateOfBirth = new DateTime(1990, 1, 1) }; var extendedCustomer = new ExtendedCustomer { name = "Medda", dateOfBirth = new DateTime(1990, 1, 1), someNewValue = "hej" }; databaseAccess.addCustomer(customer).Wait(); databaseAccess.addCustomer(extendedCustomer).Wait(); } }
public PrototypeShould() { _basicCustomer = new Customer(); _basicCustomer.FirstName = "John"; _basicCustomer.LastName = "Smith"; _basicCustomer.HomeAddress = new Address { StreetAddress = "1 Kent Street", City = "Sydney", State = "New South Wales", Country = "Australia", PostCode = "2000" }; _basicCustomer.BillingAddress = new Address { StreetAddress = _basicCustomer.HomeAddress.StreetAddress, City = _basicCustomer.HomeAddress.City, State = _basicCustomer.HomeAddress.State, Country = _basicCustomer.HomeAddress.Country, PostCode = _basicCustomer.HomeAddress.PostCode }; }