public Bike(BikePoco bikePoco) { this.BikeId = bikePoco.BikeId; this.Brand = bikePoco.Brand; this.PurchaseDate = bikePoco.PurchaseDate; this.Notes = bikePoco.Notes; this.DateOfLastService = bikePoco.DateOfLastService; this.PriceFirstHour = bikePoco.PriceFirstHour; this.PriceAdditionalHour = bikePoco.PriceAdditionalHour; this.Category = bikePoco.Category; }
public void TestCreateRental() { BikePoco bikePoco = new BikePoco { Brand = "KTM", Category = "Sport Bike", DateOfLastService = DateTime.Parse("2018/01/20"), PriceFirstHour = 3, PriceAdditionalHour = 5, PurchaseDate = DateTime.Now }; this.rentalController.CreateNewBike(bikePoco); CustomerPoco customerPoco = new CustomerPoco { Birthday = DateTime.Parse("2018/06/24"), Firstname = "Philipp", Lastname = "CreateCustomerTest", Gender = "männlich", Housenumber = 24, Street = "Marktplatz", ZipCode = 4310, Town = "Mauthausen" }; this.rentalController.CreateNewCustomer(customerPoco); BikeContext context = new BikeContext(); Bike bike = context.Bikes.Last(); Customer customer = context.Customers.Last(); Rental rental = new Rental { Bike = bike, Customer = customer, Paid = false, RentalBegin = DateTime.Parse("24.06.1999 10:00:00"), RentalEnd = DateTime.Parse("24.06.1999 11:00:00"), TotalPrice = 0 }; context.Add(rental); context.SaveChanges(); Rental selectRental = this.rentalController.GetAllRentalsByCustomerId(customer.CustomerId).Find(r => r.Customer.CustomerId == customer.CustomerId); if (selectRental == null) { Assert.Fail(); } }
public void UpdateBike(BikePoco bike) { var oldBike = this.rentalDataAccess.GetBikeById(bike.BikeId); if (oldBike != null) { this.rentalDataAccess.UpdateCustomer(oldBike, bike); } else { throw new Exception("Bike does not exist!"); } }
public void TestCreateNewBike() { BikePoco bikePoco = new BikePoco { Brand = "KTM", Category = "Sport Bike", DateOfLastService = DateTime.Parse("2018/01/20"), PriceFirstHour = 3, PriceAdditionalHour = 5, PurchaseDate = DateTime.Now }; this.rentalController.CreateNewBike(bikePoco); Bike bike = this.rentalController.GetAllAvailableBikes(new RentalBikeSystem.DTO.GetAllAvailableBikesDTO()).Find(b => b.Brand == bikePoco.Brand); if (bike == null) { Assert.Fail(); } }
public void UpdateBike([FromBody] BikePoco updateBike) { this.rentalBusinessLogic.UpdateBike(updateBike); }
public void CreateNewBike([FromBody] BikePoco newBike) { this.rentalBusinessLogic.CreateNewBike(newBike); }
public void CreateNewBike(BikePoco newPocoBike) { Bike newBike = new Bike(newPocoBike); this.rentalDataAccess.CreateNewBike(newBike); }
//Update public void UpdateCustomer(Bike oldBike, BikePoco bike) { this.bikeContext.Entry(oldBike).CurrentValues.SetValues(bike); this.bikeContext.SaveChanges(); }