/// <summary> /// Rent a handset. /// </summary> /// <param name="customer">The customer requesting the handset rental.</param> /// <returns>A new handset rental.</returns> public HandsetRental RentHandset(Customer customer) { var handset = this.GetAvailableHandsets(DateTime.Now).First(); var rental = new HandsetRental { Customer = customer, Handset = handset, WhenRentedOut = DateTime.Now, RentalExpires = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59), Pin = this.GeneratePin() }; this._persistence.GetRepository <HandsetRental>().Add(rental); this._persistence.Commit(); return(rental); }
/// <summary> /// Initialises a new instance of the <see cref="AuthenticatedHandset"/> class. /// </summary> /// <param name="rental">The <see cref="HandsetRental"/> that was used to authenticate the request.</param> public AuthenticatedHandset(HandsetRental rental) { this.Rental = rental; }
/// <summary> /// Set a <see cref="HandsetRental"/> to be inactive now. /// </summary> /// <param name="rental">The <see cref="HandsetRental"/> to deactivate.</param> public void ExpireRental(HandsetRental rental) { rental.RentalExpires = DateTime.Now; this._persistence.Commit(); }
/// <summary> /// Rent a handset. /// </summary> /// <param name="customer">The customer requesting the handset rental.</param> /// <returns>A new handset rental.</returns> public HandsetRental RentHandset(Customer customer) { var handset = this.GetAvailableHandsets(DateTime.Now).First(); var rental = new HandsetRental { Customer = customer, Handset = handset, WhenRentedOut = DateTime.Now, RentalExpires = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59), Pin = this.GeneratePin() }; this._persistence.GetRepository<HandsetRental>().Add(rental); this._persistence.Commit(); return rental; }